Yes, by playing on the RS I simplify the program.
BEGIN {RS="@" ; getline s1 < m2_file ; close(m2_file) ; RS="\n"}
(the variable m2_file is transmitted with option -v
Thank you !!
How to store into a awk variable the contents of a small file, which has several lines (obviously without affecting its content - the line breaks, the successive spaces, etc) ?
In fact I must make with awk the equivalent of
cat file | sed "s|TOTO|$toto|g;s|TITI|$titi|g;s|TATA|$tata|g"
the...
I concluded too quickly that only the first word is taken for the file passed with "|" + "-". In fact the problem is different. With file t1 and list_file yields:
t1:
one
two
three
list_file:
ident1
ident2
> cat t1 | awk '{print "NR="NR" FNR="FNR" "$0}' - list_file
NR=1 FNR=1 one
NR=2 FNR=1...
No, name is obtained with cat -n to numbering the extracted dossiers in the file of dossiers to extract. That is how I insert the two lines "start" and "end" in the original file:
cat $list_file | sed "s|$| 0ZZZ|g" | cat -n | awk '{printf "%7s %4s %08d\n",$2,$3,$1}' \
>> $work_file
cat...
Now my whole script is finished. My question on awk was part of an script whose mission was to extract dossiers from a file (we has into an other file the list of dossiers to extract). Each dossiers in the file is identified with an identifier ident1, ident2 ... and can have multiple lines.
To...
Finally I use perl, because awk converts several successive spaces into one.
By cons, how to pass variables to the perl program (the equivalent of -v var = $ var for awk) ?
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.