![]() |
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 |
| how to append spaces(say 10 spaces) at the end of each line based on the length of th | prathima | UNIX for Dummies Questions & Answers | 17 | 01-28-2009 04:10 PM |
| Print to ps2pdf print queue | Sean_69 | SUN Solaris | 2 | 10-22-2007 11:00 AM |
| Print to a ps2pdf print queue. | Sean_69 | UNIX for Dummies Questions & Answers | 1 | 10-22-2007 10:58 AM |
| Print Problem in UNIX. Need to know the option to specify the print paper size | ukarthik | HP-UX | 1 | 06-07-2007 09:35 AM |
| Strip leading and trailing spaces only in a shell variable with embedded spaces | jerardfjay | Shell Programming and Scripting | 6 | 03-07-2005 02:24 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Hi All,
file_1.txt contains aaa bbbb hhhh vvvvv mmmmm iiiii What i want is to search for the first coloumn of each line using awk.i.e as below: awk '/aaa/ {printf(<>)}' file_1.txt The print part (<>) should contain all the values(or coloumns ) in the particular line(here it is: bbbb hhhh) including the spaces between each arguments.Given that the "aaa" should not be printed. In short my output after running the above awk should be bbbb hhhh If it is the "vvvv" am searching for then the result should be mmmmm iiiii Thanks in advance JS |
|
||||
|
Quote:
but code doesnot print the spaces in the begining .. Also when i ran this in command promt other than the starting spaces everything else is working .. But am supposed to run this in a script where the pattern is received from a function call .. When i executed the script, i got error saying unamatched .. The fields in the file are unique ..Nothing is repeated ..Also the pattern for matching is always at teh first of coloumn in my file .. Once again thanks for the effort ... JS |
|
|||||
|
Code:
awk 'sub(/^aaa/,"")' filename in that case: Code:
awk 'sub(/^aaa */,"")' filename Last edited by radoulov; 01-16-2008 at 09:37 AM.. Reason: Use nawk or /usr/xpg4/bin/awk on Solaris. |
![]() |
| Bookmarks |
| Tags |
| awk, regex |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|