I have a file some.txt-rwxrw-r-- 1 ivamshky ivamshky    152 Apr  2 00:42 12.sh~-rw-rw-r-- 1 ivamshky ivamshky     58 Apr  6 19:03 a.c-rw-rw-r-- 1 ivamshky ivamshky     98 Apr  1 20:27 all.sh-rwxrwxr-x 1 ivamshky ivamshky   8509 Apr  6 19:04 a.out-rw-rw-r-- 1 ivamshky ivamshky     46 Apr  6 19:07 a.py-rw-rw-r-- 1 ivamshky ivamshky    399 Apr 18 00:37 attendance.csv-rw-rw-r-- 1 ivamshky ivamshky    341 Apr 20 01:08 attendance.sh-rw-rw-r-- 1 ivamshky ivamshky      0 Apr 19 16:21 awk-rw-rw-r-- 1 ivamshky ivamshky    212 Apr 20 01:41 awktest.shNow, I want that if a filename in current directory is present in above file, then a new coloumn is added to that line having FOUND.eg:if awktest.sh is present in pwd. then the output comes out to be:-rw-rw-r-- 1 ivamshky ivamshky    212 Apr 20 01:41 awktest.sh   FOUNDI havve written this script(With your Help, Thanks) #!/bin/bashfor fn in *do    n=$( awk -v fn=$fn '$0 ~ fn { print NR }' some.txt )    awk -v n=$n 'NR==n { $(NF+1)=Found }1' some.txt >some.outdonebut there's no new coloumn is added in the outputfile.(there are some files in pwd which are present in some.txt
Getting an error when running awk from a script
shell script;awk
Much easy it can be done with sed#!/bin/bashunset patternfor fn in *do    pattern=${pattern:+${pattern}\\|}$fdonesed -i /$pattern/s/$/ Found/ some.txt