- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: awk not outputting
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
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
тАО10-08-2004 04:08 AM
тАО10-08-2004 04:08 AM
I settled on the awk 'index' command which appears to be able to return the starting location of the string within the other string. Using the example above with S1 = "abcdef" and S2 = "cd", awk '{index($S1,$S2);}'
For my purposes a value > 0 would tell me I have a match. Fine.
I'm new to awk and have been trying to get the syntax correct. Sometimes Tru64 gives me a syntax error so I know I'm running awk. The other times I get nothing; the script just stops and I have to Ctrl-C to end it. The same thing happens when I run the simplest of awk commands (awk '{print "Hello";}' from the command line; no response so I have to Ctrl-C to get the Tru64 prompt back.
I have searched Tru64 doc, google and the man page and found lots of info but nothing on how to get the results of my awk commands to display or end up in a script variable.
What am I doing wrong?
KS
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-08-2004 04:10 AM
тАО10-08-2004 04:10 AM
Re: awk not outputting
Can anybody move it to Tru64?
KS
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-08-2004 04:13 AM
тАО10-08-2004 04:13 AM
Re: awk not outputting
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-08-2004 04:30 AM
тАО10-08-2004 04:30 AM
Re: awk not outputting
T1=addchgdel
echo $T1
T2=add
echo $T2
awk '{index(T1,T2);}'
if [ $? -ne 0 ] ; then
echo "hit"
else
echo "miss"
fi
When I run the script it responds:
addchgdel
add
Then it just hangs
Any ideas?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-08-2004 04:35 AM
тАО10-08-2004 04:35 AM
Re: awk not outputting
You missed to give that,
Try as,
T1=addchgdel
echo $T1
T2=add
echo $T2
echo "$T1 $T2" | awk '{index(T1,T2);}'
if [ $? -ne 0 ] ; then
echo "hit"
else
echo "miss"
fi
It will work there.
HTH.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-08-2004 05:00 AM
тАО10-08-2004 05:00 AM
Re: awk not outputting
..
echo "$T1 $T2" | awk '{index(T1,T2);}'
..
to
echo "$T1 $T2" | awk '{index($1,$1;}'
Another possibility is the match-operator:
T1=addchgdel
echo $T1
T2=add
echo $T2
if echo "$T1 $T2" | awk '$2 !~ $1 {exit 1}'
then echo ok
else echo not matched
fi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-08-2004 05:20 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-08-2004 05:30 AM
тАО10-08-2004 05:30 AM
Re: awk not outputting
T1=addchgdel
echo $T1
T2=add
echo $T2
echo "$T1 $T2" | awk '{ print match($1,$2) }'
if [ $? -ne 0 ] ; then
echo "hit"
else
echo "miss"
fi
It is too work there.
HTH.