- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: split on \ in awk
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
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
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-03-2003 09:43 AM
тАО07-03-2003 09:43 AM
Is there a special way to refer to \ within awk so it can be used as a field delimiter?
if [ "`grep $ORACLE_SID $MAP_DIR/system_orabase_nt`" = "" ]; then
ORACLE_VERSION=`grep -i "$HOSTNAME $ORACLE_SID " $MAP_DIR/system_orabase | awk '{split($4,a,"/"); print a[4] }'`
echo "Found in system_orabase"
else
ORACLE_VERSION=`grep -i "$REAL_HOSTNAME $ORACLE_SID " $MAP_DIR/system_orabase_nt | awk '{split($4,a,"\5c"); print a[4] }'`
echo "Found in system_orabase_nt"
fi
echo "ORACLE_VERSION = $ORACLE_VERSION"
The 2 data files are attached.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-03-2003 09:43 AM
тАО07-03-2003 09:43 AM
Re: split on \ in awk
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-03-2003 09:51 AM
тАО07-03-2003 09:51 AM
Re: split on \ in awk
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-03-2003 10:02 AM
тАО07-03-2003 10:02 AM
Re: split on \ in awk
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-03-2003 10:16 AM
тАО07-03-2003 10:16 AM
Re: split on \ in awk
awk -F"\" '{print $4}' ......file....
Tim
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-03-2003 10:17 AM
тАО07-03-2003 10:17 AM
Solutionawk -F\\ '{print $4}'
will work and is a little more obvious.
I would surrond each shell var with ${}'s e.g. ${HOSTNAME} and replace the archaic `command` with $(command) -- that becomes especially important when you need to nest commands.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-03-2003 11:27 AM
тАО07-03-2003 11:27 AM
Re: split on \ in awk
Perhaps not the answere of the awk question but to get the Oracle version out of the string, try the following:
basename `echo 'C:\Oracle\9.2.0' |tr "\134" /`
You can use the same command both for Unix and windows filenames. This tr statement does not change Unix filnames.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-03-2003 11:44 AM
тАО07-03-2003 11:44 AM
Re: split on \ in awk
awk '{print $4}' | awk -F\\ '{print $3}'
but that didn't work either.
A. Clay, I don't doubt that it should work, all I know is that it doesn't in my environment. I am running ksh vs sh. Could that be an issue?
Don
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-03-2003 11:55 AM
тАО07-03-2003 11:55 AM
Re: split on \ in awk
Can someone explain what the difference is? Since I don't get much training, I'm not up to speed on all the latest stuff (or even some of the not-so-latest stuff).
Thanks for all your input.
Don
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-03-2003 12:22 PM
тАО07-03-2003 12:22 PM
Re: split on \ in awk
Using the ()'s it is so much easier to find the single quotes, double quotes, and escaped quotes.