As elixir_sinari and alister pointed out, there are some improvements possible to your command line to get where you want.
Two of the three lines you show in post #1 are error msgs output to stderr. No piped filter will see those unless you redirect stderr.
The grep cmd is pointless. awk can do this.
If you want do stop after the first matched output, you could close the pipe.
Given your post #1 sample, my comments to elixir_sinari's suggestion combined with alister's might do the job:
Code:
snmpwalk -v 3 -u WANDL_SU -a MD5 -A vfipmpls -x DES -X VfIpMpLs -l authPriv 182.19.96.13 2>/dev/null|awk -F"[: ]" '/ae0\.784/{print $3; exit}' > outputfile
It will suppress error msgs, print the ifDescr.2500 to the outputfile as desired, and then exit and close the pipe, (hopefully) causing the snmpwalk cmd to terminate. Pls check out and come back with results.
Hi folks,
Please advise which command/command line shall I run;
1) to display the command and its output on console
2) simultaneous to save the command and its output on a file
I tried tee command as follows;
$ ps aux | grep mysql | tee /path/to/output.txt
It displayed the... (7 Replies)
How can I grep exactly a string that has .,/ characters using grep?
Example: I want to grep ONLY string1 and not string1.more or string1.more.evenmore
#lsauth ALL|grep 'string1'
All output:
string1 <--- This is the only I want.
string1.more
string1.evenmore.
more.string1... (4 Replies)
Hi,
I have written a shell script which is a combination of 5 scripts into one.
We have a Record Claim indicator in the scpt ($rc) with which we can come to an conclusion if the script failed to load the data or if the data loaded successfully.
Can any one please help me as to how to... (16 Replies)
I'm working on a script to make backup of various folder located on various host using different OS.
I got a strange behaviour because the script donět process all lines of a configuration file, the script execute only one loop even the input file have 6 lines:
This is the script:
#!/bin/bash... (4 Replies)
This has been bothering me for 3 days.
$> hostname
cepsun64amd
And I just want "cepsun",
I would normally do h=`hostname`; ${h%%64*}
But I am looking for a one-liner just for my own knowledge, because if there is a way to do this, I should know it by now.
Anyway, so is this... (2 Replies)
I am running the export command within a view to use that value inside my build script. But while executing it it is saying "export command not found"
My code is as follows:
--------------------------
#!/bin/sh
user="test"
DIR="/bldtmp/"$user
VIEW="test.view1"
echo "TMPDIR before export... (4 Replies)
Hi All,
I have a file with name
Is there a LINUX command that will help me to output the word after the 9th Underscore(_).
ie the output should be DLY in this case.
Can anybody pls help me.
Thanks much in advance,
Freddie (4 Replies)
below is the output xml string from some other command and i will be parsing it using awk
cat /tmp/alerts.xml
<Alert id="10102" name="APP-DS-ds_ha-140018-componentFailure-S" alertDefinitionId="13982" resourceId="11427" ctime="1359453507621" fixed="false" reason="If Event/Log Level(ANY) and... (2 Replies)
I am using UNIX to create a script on our system. I have setup my commands to append their output to an outage file. However, some of the commands return no output and so I would like something to take their place.
What I need
The following command is placed at the prompt:
TICLI... (4 Replies)
Discussion started by: jbrass
4 Replies
LEARN ABOUT NETBSD
msgs
MSGS(1) BSD General Commands Manual MSGS(1)NAME
msgs -- system messages and junk mail program
SYNOPSIS
msgs [-fhlpqr] [number] [-number]
msgs [-s]
msgs [-c [days]]
DESCRIPTION
msgs is used to read system messages. These messages are sent by mailing to the login `msgs' and should be short pieces of information which
are suitable to be read once by most users of the system.
msgs is normally invoked each time you login, by placing it in the file .login (or .profile if you use sh(1)). It will then prompt you with
the source and subject of each new message. If there is no subject line, the first few non-blank lines of the message will be displayed. If
there is more to the message, you will be told how long it is and asked whether you wish to see the rest of the message. The possible
responses are:
y Type the rest of the message.
RETURN Synonym for y.
n Skip this message and go on to the next message.
- Redisplay the last message.
q Drop out of msgs; the next time msgs will pick up where it last left off.
s Append the current message to the file ``Messages'' in the current directory; `s-' will save the previously displayed message. A
`s' or `s-' may be followed by a space and a file name to receive the message replacing the default ``Messages''.
m A copy of the specified message is placed in a temporary mailbox and mail(1) is invoked on that mailbox.
p The specified message is piped through PAGER, or, if PAGER is null or not defined, more(1). The commands `m', `p', and `s' all
accept a numeric argument in place of the `-'.
msgs keeps track of the next message you will see by a number in the file .msgsrc in your home directory. In the directory /var/msgs it
keeps a set of files whose names are the (sequential) numbers of the messages they represent. The file /var/msgs/bounds shows the low and
high number of the messages in the directory so that msgs can quickly determine if there are no messages for you. If the contents of bounds
is incorrect it can be fixed by removing it; msgs will make a new bounds file the next time it is run.
The -s option is used for setting up the posting of messages. The line
msgs: "| /usr/bin/msgs -s"
should be included in /etc/mail/aliases (see newaliases(1)) to enable posting of messages.
The -c option is used for performing cleanup on /var/msgs. An entry with the -c option should be placed in /etc/crontab to run every night.
This will remove all messages over 21 days old. A different expiration may be specified on the command line to override the default.
Options when reading messages include:
-f Do not print ``No new messages.''. This is useful in a .login file since this is often the case here.
-q Queries whether there are messages, printing ``There are new messages.'' if there are. The command ``msgs -q'' is often used in
login scripts.
-h Print the first part of messages only.
-r Disables the ability to save messages or enter the mailer. It is assumed that PAGER is set to something secure.
-l Option causes only locally originated messages to be reported.
number A message number can be given on the command line, causing msgs to start at the specified message rather than at the next message
indicated by your .msgsrc file. Thus
msgs -h 1
prints the first part of all messages.
-number Start number messages back from the one indicated in the .msgsrc file, useful for reviews of recent messages.
-p Pipe long messages through PAGER, or, if PAGER is null or not defined, more(1).
Within msgs you can also go to any specific message by typing its number when msgs requests input as to what to do.
ENVIRONMENT
msgs uses the HOME and TERM environment variables for the default home directory and terminal type.
FILES
/var/msgs/* database
~/.msgsrc number of next message to be presented
SEE ALSO mail(1), more(1), aliases(5)HISTORY
The msgs command appeared in 3.0BSD.
BSD April 28, 1995 BSD