bash - The variable is empty after inner loop `for` -
i know pipes proceeding in subshells, need little help.. got following code:
#!/bin/bash first="" second="" item1 in $(ls *.o) first=`nm $item1 | grep -e '\<u\>' | awk '{print2}'` item2 in $(ls *.o) second=`nm $item2 | grep -e '\<t\>' | awk '{print3}'` if [ "$first" == "$second" ]; echo "$item1 => $item2 ($second)" else echo "error!" fi done done
after script has been executed, i'm receiving empty $second (in brackets):
print_recursive.o => print_recursive.o () print_recursive.o => recfun.o () print_recursive.o => recursive.o () print_recursive.o => timeout.o ()
would mind rewrite code in right order? in advance.
always strive come minimal example. problem has nothing loops.
if have problem variable, check command sets it. in case:
second=`nm $item2 | grep -e '\<t\>' | awk '{print3}'`
that awk
command doesn't anything. guess meant {print $3}
, though won't solve problem either, nm
return multiple matching rows. want compare 2 sets? if so, sort
them first.
Comments
Post a Comment