- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: echo asterisk
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
тАО08-16-2010 11:00 AM
тАО08-16-2010 11:00 AM
echo asterisk
udi *****
jim 10
ant 19
ibm *****
input=`head -1 /tmp/tuxob.lst | awk '{print $NF}'`
If above is the script, then how do I put if conditions. i.e. If $input = '*****' do something. Because on putting $input displays files of current directory being expanded to echo *
- Tags:
- quoting
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-16-2010 11:20 AM
тАО08-16-2010 11:20 AM
Re: echo asterisk
first:
- no need for command head
- no need for command echo
You get your - doubtful - info by
awk '$NF == "*****" {print $NF;exit}' /tmp/tuxob.lst
I try to guess, what you want:
if a line has ****** as the second column, do 'something' with the first.
As an example, I check the name for existence in the NIS database in calling 'ypmatch
awk '$NF == "*****" {cmd="ypmatch "$1" passwd"; system(cmd)}' /tmp/tuxob.lst
mfG Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-16-2010 11:28 AM
тАО08-16-2010 11:28 AM
Re: echo asterisk
I have this code:
status | awk '{print $1 " " $3}' > /tmp/tuxob.lst
lines=`wc -l /tmp/tuxob.lst`
i=1
while [ $i -le $lines ]
do
input=`head -${i} /tmp/tuxob.lst | tail -1`
obup=`echo $input | awk '{print $2}'`
srcName=`echo $input | awk '{print $1}'`
if [ "$obup" = '*****' ]
then
echo "srcName is down"
fi
i=`expr $i + 1`
done
The file /tmp/tuxob.lst contains:
udi *****
jim 10
ant 19
ibm *****
and as an output I want to display udi and ibm.
Please advise.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-16-2010 12:29 PM
тАО08-16-2010 12:29 PM
Re: echo asterisk
let's look, if I understood the 'status' command and your script correctly! Try:
status | awk '$3 == "*****" {print $1,"is down"}'
I feel no need for a temporary file, but if you insist:
status | awk '$3 == "*****" {print $1,"is down"}
{print $1,$3 >"/tmp/tuxob.lst"}'
mfG Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-16-2010 10:04 PM
тАО08-16-2010 10:04 PM
Re: echo asterisk
status | awk '{print $1 " " $3}' > /tmp/tuxob.lst
cat /tmp/tuxob.lst | while read obup srcName
do
if [ "$obup" = '*****' ]
then
echo "srcName $srcName is down"
fi
done
Or:
grep ' [*][*]*$' /tmp/tuxob.lst | cut -f1
to do just what you want, display only the lines containing the '*****' at the end.
And there are lots of other solutions too.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-08-2010 06:08 AM
тАО09-08-2010 06:08 AM
Re: echo asterisk
As a general comment, if you want to prevent file name generation, disable it with 'set -f'.
For example, compare:
# cd /tmp; echo *
...with:
# cd /tmp; set -f; echo *; set +f
Regards!
...JRF...