![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | 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 here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Multiple field separators in awk? (First a space, then a colon) | doubleminus | UNIX for Dummies Questions & Answers | 3 | 04-27-2008 12:28 PM |
| Multiple input field Separators in awk. | kinksville | Shell Programming and Scripting | 4 | 04-25-2008 02:12 PM |
| using nawk to concate the fields | raychu65 | UNIX for Dummies Questions & Answers | 2 | 01-25-2008 02:26 AM |
| Append tabs at the end of each line in NAWK -- varying fields | madhunk | Shell Programming and Scripting | 6 | 07-12-2006 03:20 PM |
| Awk Multiple Field Separators | Tonka52 | Shell Programming and Scripting | 7 | 04-07-2004 06:37 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
I need help counting the fields and field separators using Nawk
I need help counting the fields and field separators using Nawk.
I have a file that has multiple lines on it and I need to read the file 1 at a time and then count the fields and field separators and then store those numbers in variables. I then need to delete the first 5 fields and the blank spaces. example: 45 21 * * * run_cron /temp "daily_files.ksh" I want to read the file that has this line and then write it to a new file with a line that looks like this: run_cron /temp "daily_files.ksh" The problem is that the the first 5 fields (which is what I really want to get rid of) are not the same for each line I am reading. Any help is much appreciated. Thanks Last edited by scrappycc; 02-05-2008 at 05:47 PM. |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
Code:
bash-3.00# cat /tmp/tmp 45 21 * * * run_cron /temp "daily_teri_files.ksh" 45 21 * * * run_cron /test "weekly_teri_files.csh" bash-3.00# while read one two three four five rest; do > echo $rest | sed 's/"$/;run_mbpro teri-daily-recon.r"/' > done < /tmp/tmp run_cron /temp "daily_teri_files.ksh;run_mbpro teri-daily-recon.r" run_cron /test "weekly_teri_files.csh;run_mbpro teri-daily-recon.r" |
|
#3
|
|||
|
|||
|
Thanks for the answer
Yes that is exactly what I want to do. I will check it out and make sure it works for my big file. Thanks for the help!
|
|
#4
|
|||
|
|||
|
Quote:
Also, awk is specifically designed to process structured data so it understands fields. using awk might be more "appropriate" in OP's case. |
|||
| Google The UNIX and Linux Forums |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|