Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 10-12-2008
Registered User
 
Join Date: Dec 2007
Posts: 153
Thanks: 9
Thanked 0 Times in 0 Posts
what does awk 1 file mean?

I have a file with no eof, and I want to change it, I know I can do awk 1 file > file2, but I would like to know what awk 1 means?

thanks
Sponsored Links
    #2  
Old 10-12-2008
cfajohnson's Avatar
Shell programmer, author
 
Join Date: Mar 2007
Location: Toronto, Canada
Posts: 2,866
Thanks: 0
Thanked 100 Times in 93 Posts
Quote:
Originally Posted by JamesByars View Post
I have a file with no eof,

In Unix, there is no such thing as EOF. Do you mean it is missing a final newline?
Quote:
and I want to change it, I know I can do awk 1 file > file2, but I would like to know what awk 1 means?

1 is a pattern that is always true. In the absence of an action ( {...} ), awk prints the line.
Sponsored Links
    #3  
Old 10-12-2008
Moderator
 
Join Date: Feb 2007
Location: The Netherlands
Posts: 7,505
Thanks: 73
Thanked 474 Times in 453 Posts
awk evaluates the 1 as true and the prints the entire line by default, including a newline.

Regards
    #4  
Old 11-01-2008
Registered User
 
Join Date: Dec 2007
Posts: 153
Thanks: 9
Thanked 0 Times in 0 Posts
thanks
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Before I delete any file in Unix, How can I check no open file handle is pointing to that file? kchinnam Solaris 12 10-06-2010 02:30 PM
Reading file names from a file and executing the relative file from shell script anushilrai Shell Programming and Scripting 4 03-10-2006 04:25 AM



All times are GMT -4. The time now is 06:58 PM.