what does awk 1 file mean? | Unix Linux Forums | Shell Programming and Scripting

  Go Back    


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

what does awk 1 file mean?

Shell Programming and Scripting


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 10-12-2008
JamesByars JamesByars is offline
Registered User
 
Join Date: Dec 2007
Last Activity: 22 November 2010, 7:05 AM EST
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
cfajohnson cfajohnson is offline Forum Advisor  
Shell programmer, author
 
Join Date: Mar 2007
Last Activity: 18 August 2014, 11:00 AM EDT
Location: Toronto, Canada
Posts: 2,877
Thanks: 0
Thanked 110 Times in 102 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
Franklin52's Avatar
Franklin52 Franklin52 is offline Forum Staff  
Moderator
 
Join Date: Feb 2007
Last Activity: 21 August 2014, 2:35 PM EDT
Location: The Netherlands
Posts: 7,703
Thanks: 121
Thanked 532 Times in 503 Posts
awk evaluates the 1 as true and the prints the entire line by default, including a newline.

Regards
    #4  
Old 11-01-2008
JamesByars JamesByars is offline
Registered User
 
Join Date: Dec 2007
Last Activity: 22 November 2010, 7:05 AM EST
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 11:56 PM.