Sponsored Content
Top Forums Shell Programming and Scripting Issue in awk parsing under while loop Post 302999051 by ananan on Monday 12th of June 2017 11:51:54 PM
Old 06-13-2017
Issue in awk parsing under while loop

Hi

I am trying to parse a grep output using awk. It works fine individually and not working under the loop with variable name assigned.

Code:
cat > file.txt
dict=/dictr/abcd/d1/wq:/dictr/abcd/d2/wq:/dictr/abcd/d3/wq:

sample tried code
Code:
Nos=`grep -w "dict" file.txt | awk -F"=" '{print $2}' | awk -F":" '{print NF-1}'`
echo "$Nos"
while [ "$Nos" -ge 1 ]
do
sPath=`grep -w "dict" file.txt | awk -F"=" '{ print $2}' | awk -F":" '{ print $(echo "$Nos") }'`
echo "$sPath" 
if [[ -s "$sPath"/*12581.log ]]; then
    FileName=`ls  "$sPath"/*12581.log |head -1`
fi
  Nos=`expr $Nos- 1`
done
#echo "$FileName"

sample output
Code:
/dictr/abcd/d1/wq:/dictr/abcd/d2/wq:/dictr/abcd/d3/wq:
/dictr/abcd/d1/wq:/dictr/abcd/d2/wq:/dictr/abcd/d3/wq:
/dictr/abcd/d1/wq:/dictr/abcd/d2/wq:/dictr/abcd/d3/wq:

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

parsing logfiles (performance issue)

-------------------------------------------------------------------------------- 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)
Discussion started by: subin_bala
4 Replies

2. UNIX for Dummies Questions & Answers

Issue with parsing config variables

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)
Discussion started by: madhukalyan
1 Replies

3. Shell Programming and Scripting

Parsing issue

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)
Discussion started by: raghunsi
2 Replies

4. Shell Programming and Scripting

While loop with awk issue

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)
Discussion started by: Stephan
3 Replies

5. Shell Programming and Scripting

awk loop issue

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)
Discussion started by: nsinha
2 Replies

6. Shell Programming and Scripting

For loop, awk command issue

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)
Discussion started by: p_satyambabu
4 Replies

7. Shell Programming and Scripting

Issue with awk script parsing log file

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)
Discussion started by: Ariean
18 Replies

8. Shell Programming and Scripting

awk - 2 files comparison without for loop - multi-line issue

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)
Discussion started by: chill3chee
2 Replies

9. Shell Programming and Scripting

Parsing a control file loop

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)
Discussion started by: The Gamemaster
14 Replies

10. Shell Programming and Scripting

Parsing via sed issue

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)
Discussion started by: boncuk
2 Replies
tex2xindy(1)							       xindy							      tex2xindy(1)

NAME
tex2xindy - a preprocessor of the xindy index processor SYNOPSIS
tex2xindy [-o] [attr_file] DESCRIPTION
tex2xindy transforms a LaTeX index file ".idx" (or an ".aux" file) into a xindy raw index file. It is a filter that reads from stdin a file in the input format of LaTeX's raw index file, i.e., with "indexentry" tags. It outputs on stdout a xindy raw index file, i.e., with "indexentry" clauses. If the option -o is not specified, tex2xindy handles ^^-notation of TeX and outputs the octet that is represented: "^^ab" in the input gets output as the octet 0xab. If "^^^^abcd" or "^^^^^^^^abcdefab" are detected, they are output as is. If the option -o is specified, tex2xindy operates in Omega mode and handles its ^^-notation: Then "^^ab", "^^^^abcd", and "^^^^^^^^abcdefab" represent Unicode characters with code points 0xab, 0xabcd, and 0xabcdefab respectively. They are output in UTF-8 encoding. If the optional argument attr_file is specified, tex2xindy writes all index key attributes into this file. DEFICITS
This program was written since it was not easily possible to extract the parser from the old makeindex system. Therefore it does not find all errors in the input as the makeindex(1) version. Additionally it uses only the default input specifiers of makeindex(1). If other input specifiers (cf. manual page of makeindex(1)) are needed, the input specifiers (starting from the pattern "KEYWORD", see below) must be changed and the program must be recompiled. The particular missing feature is configuration of the quote and the actual characters, maybe also the escape, subitem (level), and encap characters. Argument and range delimiters seem to be less of a problem. In fact, input markup handling (and thus tex2xindy) should be incorporated into the xindy kernel, to be able to specify configuration in xindy style files. SEE ALSO
texindy(1), xindy(1), makeindex(1) AUTHOR
Roger Kehr, Institut fuer Theoretische Informatik, TU Darmstadt COPYRIGHT AND LICENSE
Copyright (c) 1996,1997 Roger Kehr. Copyright (c) 2006 Joachim Schrod. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Version 1.24 2010-05-10 tex2xindy(1)
All times are GMT -4. The time now is 06:43 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy