- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: awk vs. perl ... print $1?
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-14-2003 08:54 AM
тАО07-14-2003 08:54 AM
Re: awk vs. perl ... print $1?
Could you clarify the meaning of the //?
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-14-2003 12:09 PM
тАО07-14-2003 12:09 PM
Re: awk vs. perl ... print $1?
perl -aF: -nel 'print $F[0]'/etc/passwd
Should work.
Caesar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-17-2003 06:25 AM
тАО07-17-2003 06:25 AM
Re: awk vs. perl ... print $1?
On the "//" in the Awk command.
The // means "for every line."
You didn't have // in your awk script. I don't know what it was doing.
Normally I use awk this way.
cat file | awk '
You gave awk an action to do, but did not select any lines?
other selections.
if field 2 is not billy, print the line.
awk '$2 !~ /billy/ { print $0 }'
if the line begins with hoohay, print field 3.
awk '/^hoohay/ { print $3 }'
print something at the start and end.
awk 'BEGIN { print "this is the start.\n" }
// { printf("here is a line %s\n",$0) }
END { print "this is the end." }'
steve.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-17-2003 06:34 AM
тАО07-17-2003 06:34 AM
Re: awk vs. perl ... print $1?
// is implied so...
awk '{print $1}' file
is the same as
awk '//{print $1}'
I never use // & my awk works fine!!!!
Tim
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-17-2003 06:34 AM
тАО07-17-2003 06:34 AM
Re: awk vs. perl ... print $1?
// is implied so...
awk '{print $1}' file
is the same as
awk '//{print $1}' file
I never use // & my awk works fine!!!!
Tim
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-17-2003 06:40 AM
тАО07-17-2003 06:40 AM
Re: awk vs. perl ... print $1?
Maybe // does not have to be there.
I just put it in out of habit. In any case, you see it means "grab all lines."
steve
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-28-2006 11:33 PM
тАО03-28-2006 11:33 PM
Re: awk vs. perl ... print $1?
Try this! Much more readable.
cat /etc/passwd | perl -anF: -e 'print $F[0],"\n"' -
Substitute the 0 for whichever column you want.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-01-2006 09:33 AM
тАО04-01-2006 09:33 AM
Re: awk vs. perl ... print $1?
During one of the forum upgrades however, all ['s got translated into their html [ values, and ]'s into ].
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-02-2006 06:25 PM
тАО04-02-2006 06:25 PM
Re: awk vs. perl ... print $1?
Here's me thinking I was being clever.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-22-2006 06:09 AM
тАО05-22-2006 06:09 AM
Re: awk vs. perl ... print $1?
- « Previous
-
- 1
- 2
- Next »