I do not really see what this all brings, I think I would prefer the two greps to the awk solutions, because they are easier to understand and thus to maintain. One could go even further and put everything in one awk:
This probably would make it more efficient, but one could ask if that is required and the down side is that it is also less simple...
--
Ehm.. I don't agree with that..
thank you!
the thing is, i have a very huge script that uses quite a lot of egreps like those in my first post. however, while the script runs beautifully, i notice there are just too many commands being called in it. commands that, if given thought can be combined into one by a more advanced user. which is why i created this thread.
bipinajith's one-liner solution not only helps to combine the egreps in my post, it also got rid of the sed. so in essence, his awk did what i (not an advanced user) was trying to do with 3 commands (sed, egrep, egrep).
i'm making the modifcations to my script as we speak. and i'll see if the awk solution helps to decrease the script's overall processing time.
btw, can you please combine your awk suggestion into a one-liner? i think its easier to read for a novice if anywhere is in one line. if you can, please explain the code for me.
Hi
Maybe you can suggest a nicer way to do the following:
RET_STR=$(echo ${RET} | sed -e 's/0/Object is not mapped/' \
-e 's/1/Operation Internal Error/' \
-e 's/2/Operation Invalid Arguments/' \
-e 's/3/Object is mapped/' \
-e 's/4/Path not found/') (3 Replies)
Hi Guys,
I need to set the value of $7 to zero in case $7 is NULL. I've tried the below command but doesn't work. Any ideas. thanks guys.
MEM=`ps v $PPID| grep -i db2 | grep -v grep| awk '{ if ( $7 ~ " " ) { print 0 } else { print $7}}' `
Harby. (4 Replies)
Hello,
I trying to extract text that is surrounded by xml-tags. I tried this
cat tst.xml | egrep "<SERVER>.*</SERVER>" |sed -e "s/<SERVER>\(.*\)<\/SERVER>/\1/"|tr "|" " "
which works perfect, if the start-tag and the end-tag are in the same line, e.g.:
<tag1>Hello Linux-Users</tag1>
... (5 Replies)
Hi, all of you!!!
I have this code and I won to build-in some more code.
I know this is a lot of code.
if ; then
if ; then
SYSROOT="$1"
S_SCRIPT="cd $1 ; ./etc/rc.sysinit 2>&1 &"
fi
else
... (22 Replies)
Hi,
I'm using code below to assign title for Putty Window to show user@hostname+curr directory.
Trying to read this "write only" language, can anybody help me to go thru this string, too many thing in it I can't expaing
Tx
T
export PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}:... (1 Reply)
hi,
can someone tell me how can I translate the following line from sed to awk?
`sed 's/^*:*:*:*:*:\(*\):.*/\1/
How to use code tags when posting data and code samples. (14 Replies)
Hi,
I have a number of files containing the information below.
"""""
Fundallinfo
6.3950 14.9715 14.0482
"""""
I would like to grep for Fundallinfo and use it to read the next line? I ideally would like to read the three numbers that follow in the next line and... (2 Replies)
this code below is very useful in calculating mean and quartiles. however, i would really like to translate it to awk without having to write to any external file:
#!/bin/sh
filename="tmp.txt"
sort -n $1 >$filename
rows=`wc -l $filename|cut -d' ' -f1`
q2=`echo "($rows+1)/2" |bc`
... (3 Replies)
Discussion started by: SkySmart
3 Replies
LEARN ABOUT SUSE
igawk
IGAWK(1) Utility Commands IGAWK(1)NAME
igawk - gawk with include files
SYNOPSIS
igawk [ all gawk options ] -f program-file [ -- ] file ...
igawk [ all gawk options ] [ -- ] program-text file ...
DESCRIPTION
Igawk is a simple shell script that adds the ability to have ``include files'' to gawk(1).
AWK programs for igawk are the same as for gawk, except that, in addition, you may have lines like
@include getopt.awk
in your program to include the file getopt.awk from either the current directory or one of the other directories in the search path.
OPTIONS
See gawk(1) for a full description of the AWK language and the options that gawk supports.
EXAMPLES
cat << EOF > test.awk
@include getopt.awk
BEGIN {
while (getopt(ARGC, ARGV, "am:q") != -1)
...
}
EOF
igawk -f test.awk
SEE ALSO gawk(1)
Effective AWK Programming, Edition 1.0, published by the Free Software Foundation, 1995.
AUTHOR
Arnold Robbins (arnold@skeeve.com).
Free Software Foundation Nov 3 1999 IGAWK(1)