![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| help reformat data with awk | climbak | Shell Programming and Scripting | 4 | 05-30-2008 02:17 PM |
| how to reformat a hard disk | mr_balodoy | SUN Solaris | 14 | 08-22-2007 02:29 AM |
| Reformat Crontab file | alnita | Shell Programming and Scripting | 1 | 04-11-2007 02:28 AM |
| Date Reformat | F-1 | UNIX for Dummies Questions & Answers | 2 | 04-25-2006 03:32 PM |
| reformat the file | CamTu | Shell Programming and Scripting | 3 | 03-09-2005 05:01 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
reformat date, awk and sed
The command below is getting me the output I need.
awk -F"," ' { if ($6 = 475) print "@@"$3 " " "0000" $10 "0" $1 "00000000" $8}' ${DIR1}${TMPFILE1} | sed -e 's/@@1//g' > ${DIR2}${TPRFILE} Output: 900018732 00004961160200805160000000073719 Now I need to incorporate this sed command to reformat the date to mmddyy: sed 's/^\(..\)\(..\)\(..\)\(..\)$/\3\4\2/' Any ideas... |
|
||||
|
I was able to get it done, the long way. Yes, I know, it looks funny.
awk -F"," '{ if ($6 = 475) print $1 "," "@@"$3 "," $6 "," $10 "," $8}' ${DIR1}${INFILE} | sed -e 's/.*\(200.\{5\}\)00000000.*/\1/g' -e 's/^..\(..\)\(..\)\(..\)/\2\3\1/g' | sed -e 's/@@1//g' | sed -e 's/\.//g' | awk -F"," ' { print $2 " " "0000" $4 "0" $1 "00000000" $5}' > ${DIR2}${TPRFILE} |
| Sponsored Links | ||
|
|