If sPath contains three elements that would suggest an iteration.
If $sPath/*12581.log could expand to multiple entries, that suggest another iteration.
Can any one tell me whats wrong in my original posted code, since in my actual implementation i can not do awk exact match. Since the data will be having multiple lines of same match pattern. So i am using xmllint to get the desired tag values. Hence i am unable to use this code.
Please refer my initial post wherein i have mentioned only one line in the input. But actually it will be having multiple similar lines with different values under different xml tags.
---------- Post updated at 10:01 PM ---------- Previous update was at 01:24 PM ----------
Some how i managed to attain the desired results...
I am trying to parse a grep output using awk. It works fine individually and not working under the loop with variable name assigned.
sample tried code
sample output
Quote:
Originally Posted by ananan
Hi,
Can any one tell me whats wrong in my original posted code, since in my actual implementation i can not do awk exact match. Since the data will be having multiple lines of same match pattern. So i am using xmllint to get the desired tag values. Hence i am unable to use this code.
Please refer my initial post wherein i have mentioned only one line in the input. But actually it will be having multiple similar lines with different values under different xml tags.
The following comments explain part of what I believe is wrong with your script in post #1.
Presumably, the first part of your code:
when given the above contents in file.txt will set Nos to:
and print those results. You then start a while loop with an invalid test condition:
the test -ge operator compares two numeric values, but a variable containing two pathnames separated by a <newline> character is not a numeric value.
Then we move on to the last stage of the pipeline in the command substitution in the variable assignment:
I have no idea what the intent of this code is, but what it does is a request to print the field whose field number is formed by concatenating the value of the awk variable named echo (which has not been defined in this script and, therefore, has an empty string value) and the literal string $Nos (shell variables are not expanded inside single-quoted strings). Since that concatenation does not produce a numeric value, trying to print the contents of the field number identified by a non-numeric value gives you a 2nd syntax error. And, if the script hasn't aborted yet from the two syntax errors so far, the shell variable sPath will be set to an empty string. That then leads to an if statement that tests whether or not there is a file matching the filename matching pattern /*12581.log and if there is exactly one file matching that pattern and has a size greater than zero. If more than one file is matched by that pattern, you have a 3rd syntax error (since that test only works with one operand to the test -s operator).
And, finally, after that if statement, you have another command substitution:
that is used to reset the value of the Nos shell variable to its current (non-numeric) value to one less than its current value (which is another syntax error) which, therefore, sets Nos to an empty string.
You also have unneeded uses of awk, cat, expr, and grep (some of which have already been commented on by others in this thread) but if given proper arguments, they might not do anything but waste system resources and slow down your script.
sorry I messed up the last post with too many mistakes and corrections so I closed it and opening a new one which should be clear to everyone .my apologies to the admins.
I am using sun solaris and Linux , what I want is SED to print any string (or output it to a file preferably) that does... (2 Replies)
Hi,
Let's say I have a control file like this:
RHEL apple "echo apple"
RHEL bravo "ls -l bravo*"
RHEL church "chmod church.txt"
SUSE drive "chown user1 drive.txt"
SUSE eagle "echo "eagle flies""
SUSE feather "ls -l feather*"
HP-UX google "sed 's/^Google.*$/&\
ACTION: go to... (14 Replies)
Greetings Experts,
I need to handle the views created over monthly retention tables
for which every new table in YYYYMMDD format, there is
equivalent view created and the older table which might be
dropped, the view over it has to be re-created over a dummy
table so that it doesn't fail.... (2 Replies)
Hello All,
I am trying to parse a log file and i got this code from one of the good forum colleagues, However i realised later there is a problem with this awk script, being naive to awk world wanted to see if you guys can help me out.
AWK script:
awk '$1 ~ "^WRITER_" {p=1;next}... (18 Replies)
limit.csv data
--------------
5600050 38Nhava
400077 27Bomay
rate.txt data
-------------
38NhaVA
27BomaY
27Bomay
below is my script:
for i in `cat limit.csv`
do
b=`awk '{print $1}' $i` (4 Replies)
Hi
I am not able to solve this minor issue even after a lot of trial! Will be thankful if you can help me out. This is part of a awk script and the loop is self-explanatory -
num_null_key=0 #for counting the number of null keys
num_non_null_key=0 #for counting the number of non null... (2 Replies)
Hi folks.
I am trying to use a while loop along with awk to get the colums where 2 specific words are found.
Here is the output of the command i run where i need to pull the column numbers if specific words are found:
State Type Rebal Sector Block AU Total_MB Free_MB ... (3 Replies)
Scripting geeks please advice how this script should parse the input parameter to File Name convention to search the strings. Enclosed is the basic view of the search architecture.
##*******************************************************************************************************
## ... (2 Replies)
I am using MKS tool kit on windows server. One config variable is defined in windows environment and I am trying to use that variable.
# Below RootDir is defined in windows
RootDir="\\f01\var"
# in unix script
details="$RootDir/src|$RootDir/tgt"
src=`echo $details|awk -F '|' '{print... (1 Reply)
--------------------------------------------------------------------------------
Hi All,
I am reading some logfiles and parsing data and printing to some textfile.
Here is my code
OLDIFS=$IFS
IFS='
' # just a newline, in single quotes
while read data
do
if
then
#Parsing the... (4 Replies)