![]() |
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 |
| Remove trailing G | Heathe_Kyle | Shell Programming and Scripting | 3 | 04-14-2008 10:56 AM |
| How to remove trailing spaces | mahek_bedi | UNIX for Dummies Questions & Answers | 2 | 08-10-2007 07:21 AM |
| Adding Trailing Spaces to a file | 222001459 | UNIX for Dummies Questions & Answers | 1 | 11-04-2004 03:23 PM |
| Leading and Trailing Spaces | sleepster | Shell Programming and Scripting | 7 | 10-29-2003 11:48 PM |
| re: removing trailing space from lines | oombera | Shell Programming and Scripting | 1 | 06-19-2003 10:12 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
awk evaluates the 1 as true and the prints the entire line by default, including a newline.
Code:
echo 'foo' | awk '/foo/{print}1'
|
|
||||
|
Quote:
Anyway, the default action of awk is to print the record right, even if the 'print' statement is missing? Last edited by royalibrahim; 10-28-2008 at 05:34 AM.. |
|
||||
|
Quote:
Code:
$ echo 'foo' | awk '/foo/' #default action
foo
$ echo 'foo' | awk '/foo/{print}' #defined action
foo
$ echo 'foo' | awk '/foo/{$1="bar"}' #defined action
$ echo 'foo' | awk '/foo/{print}1' #defined action and default action
foo
foo
$ echo 'foo' | awk '/foo/{$1="bar"}1'
bar
|
|
||||
|
Thanks danmero, I got the essence !! hat's off
|
| Sponsored Links | ||
|
|