For loop inside awk to read and print contents of files
Hello,
I have a set of files Xfile0001 - Xfile0021, and the content of this files (one at a time) needs to be printed between some line (lines start with word "Generated") that I am extracting from another file called file7.txt and all the output goes into output.txt. First I tried creating a for loop over the Xfiles, and inside the loop the awk code, but didn't work, I understand I have to use the for loop inside the awk command, but after trying many times, I am not getting the output I am looking for.
So far this is one of the several versions I have:
So far this gives me an error, now I realized the question mark is not properly understood as 'interchangeable' character within awk, and also the print "$i" prints literally $i and not the content of the corresponding Xfile. I have recently started using more unix commands to try to do more efficiently my work, and its been very useful (whenever I get through this kind of things). I will really appreciate if someone can help me here.
By the way, the output I expect to have on output.txt should look like this:
Thank you very much,
Hi all,
In a while loop, like below...
while read line
do
read choice
case $choice in
1)
echo "xxx"
esac
done < file
why I can't run the read choice???? (3 Replies)
Hi all
Does anyone have a script that will allow me to stop inside a while read loop.
I want to pause the loop until a enter is pressed.
e.g.
While read line
do
echo something
if LINECOUNT > 40
then
read ENTER?"PRESS ENTER TO CONT..."
... (3 Replies)
Im want to print filename inside loop .. the code im using :-
Filename_1=abc_20090623_2.csv.lk
Filename_2=def_20090623_2.csv.lk
i want to extract filename till .csv eg
Filename_1=abc_20090623_2
Filename_2=def_20090623_2
How can i do this inside the for loop
... (3 Replies)
Hi,
I have 100 files in a directory.
Each file have the following format
>CtbRe01234
fdfjdhfkdfkd
>CtL2B0456
gjfgfkgjfkgjfk
>CmdrE05768
fghdjskksllfkLike this I have many files in the directory.
What I want is; rename the header content in each file such that the above file... (6 Replies)
Hi,
Need help in writing a script to read the contents of this file test
Test
00a
00b
00c
00d
00e
00f
where it need to read each line to give a display such as
form meta from dev 00a , config=Striped; add dev 00b:00f to meta 00a
Can any one help me in writing this script (2 Replies)
Hi,
I am reading file records inside a while loop,
and want to update the record when certain condition is met.
How can I update a file while being read?
I want to avoid using temporary files, copy, rename, ...
while IFS=',' read -r f1 f2
do
function(f1,f2)
if
then
<add... (1 Reply)
I have files named with different prefixes. From each I want to extract the first line containing a specific string, and then print that line along with the prefix.
I've tried to do this with a while loop, but instead of printing the prefix I print the first line of the file twice.
Files:... (3 Replies)
Hi,
This query is a part of a much more lengthy script.
I wish to look for all the files in a folder named "data" which in this case has two files i.e. plan.war and agent.properties. For all the files found under data I wish to ask the user as to where they wish copy the files to.
Below,... (14 Replies)
Discussion started by: mohtashims
14 Replies
LEARN ABOUT REDHAT
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)