Unix/Linux Go Back    


Shell Programming and Scripting Unix shell scripting - KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and shell scripts and shell scripting languages here.

what does awk 1 file mean?

Shell Programming and Scripting


Closed Linux or Unix Question    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 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 Unix and Linux 10-12-2008
cfajohnson's Unix or Linux Image
cfajohnson cfajohnson is offline Forum Advisor  
Shell programmer, author
 
Join Date: Mar 2007
Last Activity: 5 April 2015, 4:53 PM EDT
Location: Toronto, Canada
Posts: 2,882
Thanks: 0
Thanked 117 Times in 106 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 Unix and Linux 10-12-2008
Franklin52's Unix or Linux Image
Franklin52 Franklin52 is offline Forum Staff  
Moderator
 
Join Date: Feb 2007
Last Activity: 18 April 2015, 9:26 AM EDT
Location: The Netherlands
Posts: 7,730
Thanks: 128
Thanked 544 Times in 512 Posts
awk evaluates the 1 as true and the prints the entire line by default, including a newline.

Regards
    #4  
Old Unix and Linux 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 Linux or Unix Question

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Unix or Linux Image 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 09:09 AM.