zvtral
1
how i need help again
i have file input.txt like this
48:20111008_20111122:31231|123|
78:20111008_20111122:435453|321112|
where 48 and 78 is line number 20111008_20111122 is a file and 31231|123| i want get in file, i am using manual awk for get that file like this
awk 'NR==48 {print;exit}' 20111008_20111122 >> filer
awk 'NR==78 {print;exit}' 20111008_20111122 >> filer
now what should i do if input.txt can looping using the awk:confused: please helpme
thx for your advice
Just to print 2nd, 4th and 8th line using loop ..
$ for i in 2 4 8 ; do nawk -v lno="$i" 'NR==lno {print;exit}' infile; done
where 48 and 78 is line number 20111008_20111122 is a file and 31231|123| i want get in file
i dont understand the above highlighted one. Can you provide some sample input files and outputfiles.
ygemici
4
what is your desired output?
while read line
do
lno=$(echo $line | cut -d: -f1)
fname=$(echo $line | cut -d: -f2)
nawk -v lno="$lno" 'NR==lno{print;exit}' ${fname} >> filer
done < input.txt
1 Like
zvtral
6
hlow @jayan
thx for your respon
bu its same with awk
awk 'NR==48 {print;exit}' 20111008_20111122 >> filer
awk 'NR==78 {print;exit}' 20111008_20111122 >> filer
i just want to create shell
for this file
48:20111008_20111122:31231|123|
78:20111008_20111122:435453|321112|
can do autolooping using awk like above meybe i think using for i or while
but i can't for substitution this variable:wall:
---------- Post updated at 04:37 AM ---------- Previous update was at 04:28 AM ----------
its index i create for get 31231|123| in big file so i must grep that with line number and the master(20111008_20111122) file
---------- Post updated at 04:42 AM ---------- Previous update was at 04:37 AM ----------
that's i need thx @itkamaraj and @jayan_jay
ygemici
7
you can try this
# awk -F':' '{system("awk NR=="$1"{print} " $2)}' infile.txt >> filer