![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Shell program:Help required on file formating | udiptya | UNIX for Dummies Questions & Answers | 6 | 02-04-2008 05:10 AM |
| Help required on file formating | udiptya | UNIX for Dummies Questions & Answers | 1 | 01-31-2008 09:25 AM |
| formating array file output using perl | seismic_willy | Shell Programming and Scripting | 4 | 03-22-2007 02:23 AM |
| Formating mailx text file for Lotus Notes users | lidoiwo | Forum Support Area for Unregistered Users & Account Problems | 0 | 10-29-2005 12:45 PM |
| text formating/Text space padding | hugow | UNIX for Dummies Questions & Answers | 6 | 06-29-2005 10:49 AM |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
Formating text from a script into a log file
Using a for loop I am able to get the following log file below. I would like o change the format a bit as is indicated lower down. I have looked at awk and sed but somehow is not getting any joy. I am a bit new to ksh scripting. Please assist.
This is the format of my current log file after the script has run. /edi/iTracTEST/sessions/otherreceive/nohup.out @ 08:19:46 from 63 - 63 /edi/iTracTEST/sessions/payroll/nohup.out @ 08:19:46 from 52395 - 63 /edi/iTracTEST/sessions/payrollmsg/nohup.out @ 08:19:46 from 56931 - 63 As from the first record/line. The path and file name is already in a variable from a the for loop in the script. The "@" is echoed. The time is coming from the date command. The "from" is echoed. The first 63 is the initial file size in bytes as from a variable in the for loop. The "-" is echoed. The second 63 is the current/new file size as from a variable in the for loop. I would like the log file to look like this. !!!Notice I have swapped the sizes!!! /edi/iTracTEST/sessions/otherreceive/nohup.out 08:19:46 63 63 /edi/iTracTEST/sessions/payroll/nohup.out 08:19:46 63 52395 /edi/iTracTEST/sessions/payrollmsg/nohup.out 08:19:46 63 56931 This just make the log file more readable. Here is some of the code, thus far. sess_path=/edi/iTracTEST/sessions/ ls -pl /edi/iTracTEST/sessions/ | awk '$1 ~ /^d/ $9 ~ /\/$/' | awk '{print $9}' > `pwd`/temp/`date +"%C%y%m%d"`.tmp for nohup_loc in $(cat `pwd`/temp/`date +"%C%y%m%d"`.tmp) do nohup_loc2=$sess_path$nohup_loc"nohup.out" if test -s $nohup_loc2 then cur_fsize=`ls -l $nohup_loc2 | awk '{print $5}'` echo !!! Reset nohup.out file at `date` !!! > $nohup_loc2 new_fsize=`ls -l $nohup_loc2 | awk '{print $5}'` echo $nohup_loc2 @ `date +%H:%M:%S` from $cur_fsize - $new_fsize >> `pwd`/log/`date +"%C%y%m%d"`_nohup_reset.log fi done |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|