'awk' version of this Python code? -
this python code:
with open('a') f: a, b = f a, b = a.strip(), b.strip()
while awk code:
awk '{printf $1":"}'
i modify awk code can python code above does.
as seen above, awk code mess.
i need grab line 1 , 2 file a
, permit me use variables. possible in python code.
or perhaps there else native linux?
that should of?
if not mistaken, there is:
but fastest of awk.
i hope python code has error/exception handling, in case file a
has more 2 lines.
i assume file has 2 lines, , in awk:
awk '{a[nr]=$0}end{ #here whatever a[1] (a) , a[2] (b)}' file
for example:
kent$ seq 2|awk '{a[nr]=$0}end{print "hello "a[1]; print "hi "a[2]}' hello 1 hi 2
or this:
kent$ seq 2|awk '{a[nr]=$0}end{printf "%s:%s\n",a[1],a[2]}' 1:2
i hope helps.
Comments
Post a Comment