![]() |
|
|
google unix.com
|
|||||||
| Forums | Casino | Register | Forum Rules | Links | Albums | FAQ | Members List | 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 02:23 PM |
| Leading and Trailing Spaces | sleepster | Shell Programming and Scripting | 7 | 10-29-2003 10:48 PM |
| re: removing trailing space from lines | oombera | Shell Programming and Scripting | 1 | 06-19-2003 10:12 AM |
![]() |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|||
|
awk syntax doubt - trailing 1 value
In the below awk syntax, what does the value '1' signify?
awk '{....}1' file some eg: Code:
awk '{gsub(/[^[:cntrl:]]/,"")}1'
awk 'BEGIN{ORS=""}1'
awk '{ORS=(!(NR%5)?"":"\n")}1'
|
| Sponsored Links |
|
|||
|
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 04: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
|
![]() |
| Bookmarks |
| Tags |
| None |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|