- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: "awk" usage
Categories
Company
Local Language
Forums
Discussions
Knowledge Base
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Forums
Discussions
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
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
02-22-2004 09:14 PM
02-22-2004 09:14 PM
"awk" usage
How to print all the fields(seperated by field-seperator) in a line using awk ??
Specifically, say to print from $2 through to last field $NF
Thanks & Regards,
Ramesh.K.R.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2004 09:35 PM
02-22-2004 09:35 PM
Re: "awk" usage
{ split($0,tab);
for(i=2; i<= NF;i++) printf("%s ",tab[i]);
printf("\n");
}'
this take defualt separator;
check man awk for split with a different separator.
Regards,
Jean-Luc
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2004 09:45 PM
02-22-2004 09:45 PM
Re: "awk" usage
Perhaps mere easy to use cut.
cat /etc/passed |cut -d: -f 2-
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2004 09:46 PM
02-22-2004 09:46 PM
Re: "awk" usage
awk -F":" '{ for(i=2; i<= NF;i++){print $i}}'
change the ":" to your seperator.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2004 09:54 PM
02-22-2004 09:54 PM
Re: "awk" usage
Mark, your solution woudl print a line per field.
Try this (where x=2 specifies the first field):
awk '{x=2;line=$(x++); for (i=x;i<=NF;i++){line = line FS $(i) };print line}' < your-file
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2004 10:06 PM
02-22-2004 10:06 PM
Re: "awk" usage
-Karthik S S
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2004 10:33 PM
02-22-2004 10:33 PM
Re: "awk" usage
printf "%s" $i
And put an extra "print" at the end if you wanted to terminate each line of output with a new line. However, this just becomes an expensive "cut" as Leif suggests above.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2004 10:57 PM
02-22-2004 10:57 PM
Re: "awk" usage
cat
do
set -- $line
shift
echo $*
done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2004 01:03 AM
02-23-2004 01:03 AM
Re: "awk" usage
Try below,
awk -F'{print$1"
Hope this helps
Regards
Prashant
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2004 09:02 PM
02-24-2004 09:02 PM
Re: "awk" usage
Simulate echo command (see echo(1) ):
BEGIN { # Simulate echo(1)
for (i = 1; i < ARGC; i++) printf "%s ", ARGV[i]
printf "\n"
exit }
Just change "for (i = 1;..." to for (i = 2:..."
-- Graham
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-25-2004 04:41 PM
02-25-2004 04:41 PM
Re: "awk" usage
Ramesh.K.R.