![]() |
|
|
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 |
| take last column includning spaces also | Satyak | Shell Programming and Scripting | 4 | 10-31-2008 06:05 AM |
| fourth field is number in a line | Satyak | Shell Programming and Scripting | 4 | 10-15-2008 01:19 PM |
| need help to remove spaces from first column | tayyabq8 | Shell Programming and Scripting | 4 | 01-28-2006 04:40 AM |
| mandrake linux 10 fourth cd MD5 checksum | littleghost | Linux | 2 | 06-10-2004 07:50 AM |
| removing trailing spaces of a particular column in a file | rooh | UNIX for Dummies Questions & Answers | 2 | 01-12-2002 11:34 AM |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
Use awk to have the fourth column with spaces
Hi Gurus, We have a ftpserver from which we do a dir command and output it to a local file. The content of the ftpfile is: Code:
07-15-09 06:06AM 5466 ABC_123_ER19057320090714082723.ZIP 07-15-09 06:07AM 3801 ABC_123_ER19155920090714082842.ZIP 07-15-09 06:07AM 2034 ABC_123_ER19257020090714083003.ZIP 07-15-09 06:07AM 5346 ABC_123_ER19456120090714083105.ZIP 07-15-09 06:07AM 50188 ABC_123 4507131004299717363.ZIP 07-15-09 06:07AM 10867 ABC_69 ER194561.ZIP 07-15-09 06:07AM 73183 ABC_69_ER194631.ZIP 07-15-09 06:07AM 1576 ABC_69_ER195427.ZIP 07-15-09 06:07AM 5880 ABC_69_ER195428.ZIP I generally use awk '{print $4}' ftpfile. But, I realized that the filename in the ftp might contain spaces. So I came up with the command: Code:
awk '{i=4;while (NF>=i) {print $i;i++}}' ftplist
But the above command prints new line for every print I give. I want it in the same line. I tried using cut but it doesn't help. On an ad-hoc basis, I am currently using the below command: awk '{if (NF!=4) {print $4,$NF}else {print $4}}' ftplist The above command prints what I want but, I assume here that the filename will have only one space. Please suggest. |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|