Whether Shell script can do this task ???


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Whether Shell script can do this task ???
# 8  
Old 11-23-2012
To answer your first question:-
Where There is a Shell There is a Way - ULF Smilie

Try this:-
Code:
awk -F, 'NR>1 { split($5,ARR," "); $5=ARR[1]","ARR[2]" "ARR[3]; print; } ' OFS=, file.csv

# 9  
Old 12-02-2012
I have one more file (.txt) in which date format is like this
2012-4-12
2012-3-12

I want to change the format to DD-Month-Year

How can I do this..

# 10  
Old 12-03-2012
If your date command support -d option, then you can try:-
Code:
DT="2012-4-12"

Code:
date -d"$DT" +"%d-%b-%Y"
12-Apr-2012

Code:
date -d"$DT" +"%d-%B-%Y"
12-April-2012

# 11  
Old 12-03-2012
Quote:
Originally Posted by Akshay Hegde
I have one more file (.txt) in which date format is like this
Code:
2012-4-12 
2012-3-12

I want to change the format to DD-Month-Year

How can I do this..
Code:
awk -F- '
 BEGIN { months = "JanFebMarAprMayJunJulAugSepOctNovDec" }
 {
   year = $1; month = $2; day = $3
   printf "%02d-%s-%d\n", day, substr( months, (month - 1) * 3 + 1, 3 ), year
 } ' "$file"

# 12  
Old 12-03-2012
this works but it has to read file and has to write to another new file with new date format, anyways, thanks
Image bipinajith

Last edited by Akshay Hegde; 12-03-2012 at 12:50 AM.. Reason: modify
# 13  
Old 12-03-2012
Quote:
Originally Posted by Akshay Hegde
this works but it has to read file and has to write to another new file with new date format
Then redirect the output to a new file.
# 14  
Old 12-03-2012
Awesome your code will fulfill my requirement...thank you
@Image cfajohnson
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Need list of input and output parameter of task in a text file, using shell script

//file begin ===== //some code task abcd_; input x; input y,z; //some comment output w; //some comment reg p; integer q; begin //some code end endtask : abcd_ //some code //file end ===== expected output from above... (1 Reply)
Discussion started by: rishifrnds
1 Replies

2. Shell Programming and Scripting

Script for database task.

Hi, I need help in creating script for "User password reset in database" by logging into database from linux server and resetting the user password. Could you please provide the script for this task? Steps are given below. 1. Login into database from server sqlplus... (5 Replies)
Discussion started by: Maddy123
5 Replies

3. Shell Programming and Scripting

Run a task in a script at a particular time

I have an ETL process that triggers a shell script. This script picks the files created by the ETL process and does an SFTP. These are huge files. Due to infrastructure limitations, we need to trigger the actual SFTP part only during the 2nd, 16th, 31st and 46th minute of an hour. Please let me... (2 Replies)
Discussion started by: vskr72
2 Replies

4. Shell Programming and Scripting

Can any programmer do this task in shell script...

input file's one set header is this, ----------------------------------------------------- OUTPUT FROM ASCII FILE: CAST #1 ----------------------------------------------------- CC Cruise Latitude Longitude YYYY MM DD Time Cast #Levels CA 8504 50.083 -144.883 1970 1 2... (6 Replies)
Discussion started by: Akshay Hegde
6 Replies

5. Shell Programming and Scripting

command task script

ksh $CODE/dis/scripts/IS_BTEQ_LZ_TABLE_AUDIT.sh DIS_BTEQ LZ_DIS_LOAD_LOG_KEY > $CODE/dis/logs/lz_table_audit_`date '+%Y%m%d_%H%M%S'`.log 2>&1 Can some one tell me what the above script is doing? As per my understanding we are executing the script and sending the output to a log file. The... (4 Replies)
Discussion started by: karthikkasarla
4 Replies

6. Homework & Coursework Questions

Shell scripting task

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: Hi all, I am new to shell scripting. And I have a task to do, I tried all possible ways to solve this, but... (8 Replies)
Discussion started by: Strongid
8 Replies

7. Shell Programming and Scripting

Shell scripting task

Hi all, I am new to shell scripting. And I have a task to do, I tried all possible ways to solve this, but didn't. Iwas wondering maybe someone could help me. So I have a random file something like this Andrew John Mike Alfa Omega Beta And I need to create scrip witch would filter any... (1 Reply)
Discussion started by: Strongid
1 Replies

8. Shell Programming and Scripting

last task for my script

hi, infile- create table salary ( occupation_code char(40), earnings decimal(10,2), occ_yearend integer ); outfile- salary:create table salary salary:( occupation_code char(40), salary: earnings decimal(10,2), salary: occ_yearend integer salary:); Thanks. (4 Replies)
Discussion started by: dvah
4 Replies

9. Shell Programming and Scripting

comment and Uncomment single task out of multiple task

I have a file contains TASK gsnmpproxy { CommandLine = $SMCHOME/bin/gsnmpProxy.exe } TASK gsnmpdbgui { CommandLine = $SMCHOME/bin/gsnmpdbgui.exe I would like to comment and than uncomment specific task eg TASK gsnmpproxy Pls suggest how to do in shell script (9 Replies)
Discussion started by: madhusmita
9 Replies

10. Shell Programming and Scripting

Optimized way of doing the task in shell programming

Hi I have a file consists of the following similar lines (10 mb file) 2008-05-15 02:15:38,268 RMSConnectionFactory - Setting session state for connection. 2008-05-15 02:15:38,277 RMSConnectionFactory - Returning WS connection. My task is to find out any missing second lines for... (14 Replies)
Discussion started by: pcjandyala
14 Replies
Login or Register to Ask a Question