- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: awk question
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
Forums
Discussions
Discussions
Discussions
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
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
04-09-2002 11:24 PM
04-09-2002 11:24 PM
I have a file where fields are seprated by ** .
I need to use awk with -F option to select the second field.
If the fields are seprated by *, i am able to select by using -F'*' but for **, i have tried different combinations but nothing is working.I tried -F"**" , -F'**' , -F\*\* but no luck.
Thanks
AR
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-09-2002 11:36 PM
04-09-2002 11:36 PM
Re: awk question
the field separator is supposed to be one character only. So if "**" is used in the input file, use "*" as field separator, and skip those empty fields between the double "*".
good luck,
Thierry.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-09-2002 11:38 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-09-2002 11:45 PM
04-09-2002 11:45 PM
Re: awk question
This worked as a quick test
echo 1**2|awk -F "[*][*]" '{print $2}'
Steve Steel
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-09-2002 11:47 PM
04-09-2002 11:47 PM
Re: awk question
sed 's/\*\*/\|/g'
to replace the "**" delimiter with "|".
Then run awk using -F\|
HTH.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-10-2002 12:38 AM
04-10-2002 12:38 AM
Re: awk question
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-10-2002 01:52 AM
04-10-2002 01:52 AM
Re: awk question
$> cat testfile
11**22**33
44**55**66
$> awk '{FS="\*\*"}{print $2}'testfile
22
55
Regards,
Ceesjan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-10-2002 04:42 AM
04-10-2002 04:42 AM
Re: awk question
awk expects as -F argument a regular expression. Because * is a multiplier in a regex, you have to define it as a character class.
e.g:
echo 1**2 | awk -F '[*][*]' '{print $2}'
echo 1**2 | awk -F '[*]{2}' '{print $2}'
Heiner
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-10-2002 10:21 AM
04-10-2002 10:21 AM
Re: awk question
You tried F"**" , -F'**' , -F\*\* but you didn't try -F'\\**'
Try two backslashes for two ** like this
ON HP's
echo "1**2**3**4" | awk -F'\\**' '{print $3,$4}'
use nawk on Sun's with the same syntax
Thanks,
Shabu