- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: shell script
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
тАО06-08-2005 03:14 AM
тАО06-08-2005 03:14 AM
shell script
cat file1
13344 domain0.com
44555 domain1.com
.
.
I need filed 2 domains:
for i in `cat file1|awk '{print $2}'
do
......
done
My output , obtain wiht field 1:
13344 domain0.com
44555 domain1.com
since it could do this
- Tags:
- awk
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-08-2005 03:33 AM
тАО06-08-2005 03:33 AM
Re: shell script
for i in `cat file1 file2 | awk '{print $2}'`
> do
> echo $i
> done
domain0.com
domain1.com
assuming you mean want the second field from both files.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-08-2005 05:38 AM
тАО06-08-2005 05:38 AM
Re: shell script
cat file1 file2 | cut -d" " -f2
live free or die
harry d brown jr
- Tags:
- cut
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-08-2005 07:48 AM
тАО06-08-2005 07:48 AM
Re: shell script
awk '{print $2}' file1 file2
Marlou
- Tags:
- evil cat
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-08-2005 08:02 AM
тАО06-08-2005 08:02 AM
Re: shell script
cut -d" " -f2 file1 file2 ...
cut is at least twice as fast as awk. You can dig a ditch with a shovel, but a backhoe is a real tool.
live free or die
harry d brown jr
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-08-2005 08:54 AM
тАО06-08-2005 08:54 AM
Re: shell script
But just cause you can do it a million ways,
here's another way.
cat file1 | sed -e "s/^.* //"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-08-2005 09:15 AM
тАО06-08-2005 09:15 AM
Re: shell script
awk '{ print $2 }' file1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-08-2005 05:17 PM
тАО06-08-2005 05:17 PM
Re: shell script
and i also prefer to use as Tom's suggestion
awk '{ print $2 }' file1
Goo Luck,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-08-2005 05:57 PM
тАО06-08-2005 05:57 PM
Re: shell script
To get second field from a file you can use awk or cut as,
awk '{ print $2 }' file1
cut -d" " -f2 file1
hth.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-09-2005 01:43 PM
тАО06-09-2005 01:43 PM
Re: shell script
#cat temp
44555 domain1.com
44555 domain1.com
44555 domain1.com
44555 domain1.com
44555 domain1.com
# cat temp|awk '{print $2}'
domain1.com
domain1.com
domain1.com
domain1.com
domain1.com
YOU CAN SET DELIMETER BY -F LIKE THIS
#cat temp|awk -F ' ' '{print $2}'
domain1.com
domain1.com
domain1.com
domain1.com
domain1.com
#cat temp|awk -F '.' '{print $2}'
com
com
com
com
HTH
tienna