unix - Dealing with cat and head in a bash loop -


i trying add 2 lines of text 1 file beginning of bunch of other files using loop in bash command line.

i tried in command line:

$for in *.txt; head -2 ../../041_r_def_c.txt > x; cat >> x; \mv x i; done 

but gives me error:

cat: i: no such file or directory 

i tried move 1 line beginning of files:

$for in *.txt; echo "#c wavelength d %4.0f angstrom"|cat - > /tmp/out && mv /tmp/out i; done cat: i: no such file or directory cat: i: no such file or directory cat: i: no such file or directory 

i thought carry name of .txt file, don't think is. how can carry name of file/play role of file?

in loop, i variable, need access contents of variable $, should cat $i >> x. otherwise, thinks want cat file named i, doesn't exist. $i gives name stored inside variable i.

you run same issue mv... want \mv x $i


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -