loops - Adding text before each line in file in linux -


text file has sample.txt

a/b/1 b/f/2 y/z/3 a/y/4 t/q/5 

want output

a/1 a/2 a/3 a/4 a/5 

tried code

dir="a/" num=$(wc -l < sample.txt)  ((i=1; i<=$num; i++));   echo "$dir""`awk -f "/" '{print $nf}' sample.txt`"  echo "$i"  break  done 

but gives me output

a/1 2 3 4 5 

issue using awk updating first row. please

awk -f'/' '{print "a/"$3}' sample.txt 

(or)

awk -f'/' '{print "a/"$nf}' sample.txt 

Comments

Popular posts from this blog

python - Operations inside variables -

Generic Map Parameter java -

arrays - What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it? -