Reputation: 2635
I have two files. One file has name with spaces and the other the spaces have been replace with underbar by the mighty and formidable tr commands.
cat /tmp/crap2
Effective awk Programming, 3rd Edition.pdf
Fashion Photography by Edward Steichen in the 1920s and 1930s (15).jpg
Fashion Photography by Edward Steichen in the 1920s and 1930s (19).jpg
Fashion Photography by Edward Steichen in the 1920s and 1930s (30).jpg
Fashion Photography by Edward Steichen in the 1920s and 1930s (4).jpg
sed & awk, 2nd Edition.pdf
cat /tmp/crap
Effective_awk_Programming,_3rd_Edition.pdf
Fashion_Photography_by_Edward_Steichen_in_the_1920s_and_1930s_(15).jpg
Fashion_Photography_by_Edward_Steichen_in_the_1920s_and_1930s_(19).jpg
Fashion_Photography_by_Edward_Steichen_in_the_1920s_and_1930s_(30).jpg
Fashion_Photography_by_Edward_Steichen_in_the_1920s_and_1930s_(4).jpg
sed_&_awk,_2nd_Edition.pdf
I want to make output like this for display for to the file makinng display one with underbar and the other with not the underbar:
Effective_awk_Programming,_3rd_Edition.pdf
Effective awk Programming, 3rd Edition.pdf
Fashion_Photography_by_Edward_Steichen_in_the_1920s_and_1930s_(15).jpg
Fashion Photography by Edward Steichen in the 1920s and 1930s (15).jpg
Fashion_Photography_by_Edward_Steichen_in_the_1920s_and_1930s_(19).jpg
Fashion Photography by Edward Steichen in the 1920s and 1930s (19).jpg
Fashion_Photography_by_Edward_Steichen_in_the_1920s_and_1930s_(30).jpg
Fashion Photography by Edward Steichen in the 1920s and 1930s (30).jpg
Fashion_Photography_by_Edward_Steichen_in_the_1920s_and_1930s_(4).jpg
Fashion Photography by Edward Steichen in the 1920s and 1930s (4).jpg
sed_&_awk,_2nd_Edition.pdf
sed & awk, 2nd Edition.pdf
but when i use bash command with while loop and nested for loop I get big mess for outputs:
$ while read line ; do for i in $(cat /tmp/crap); do echo $i ; done ; echo $line ; done < /tmp/crap2
Effective_awk_Programming,_3rd_Edition.pdf
Fashion_Photography_by_Edward_Steichen_in_the_1920s_and_1930s_(15).jpg
Fashion_Photography_by_Edward_Steichen_in_the_1920s_and_1930s_(19).jpg
Fashion_Photography_by_Edward_Steichen_in_the_1920s_and_1930s_(30).jpg
Fashion_Photography_by_Edward_Steichen_in_the_1920s_and_1930s_(4).jpg
sed_&_awk,_2nd_Edition.pdf
Fashion Photography by Edward Steichen in the 1920s and 1930s (30).jpg
cat /tmp/crap)
cat /tmp/crap
Effective_awk_Programming,_3rd_Edition.pdf
Fashion_Photography_by_Edward_Steichen_in_the_1920s_and_1930s_(15).jpg
Fashion_Photography_by_Edward_Steichen_in_the_1920s_and_1930s_(19).jpg
Fashion_Photography_by_Edward_Steichen_in_the_1920s_and_1930s_(30).jpg
Fashion_Photography_by_Edward_Steichen_in_the_1920s_and_1930s_(4).jpg
sed_&_awk,_2nd_Edition.pdf
Fashion Photography by Edward Steichen in the 1920s and 1930s (4).jpg
cat /tmp/crap)
cat /tmp/crap
Effective_awk_Programming,_3rd_Edition.pdf
Fashion_Photography_by_Edward_Steichen_in_the_1920s_and_1930s_(15).jpg
Fashion_Photography_by_Edward_Steichen_in_the_1920s_and_1930s_(19).jpg
Fashion_Photography_by_Edward_Steichen_in_the_1920s_and_1930s_(30).jpg
Fashion_Photography_by_Edward_Steichen_in_the_1920s_and_1930s_(4).jpg
sed_&_awk,_2nd_Edition.pdf
sed & awk, 2nd Edition.pdf
I have tried other scripts with changing IFS and then making different cat file right now what i do is
paste /tmp/crap /tmp/crap2
two file and use vi to make edits
Upvotes: 1
Views: 74
Reputation: 246774
Use 2 file descriptors:
while read -u3 c1 && read -u4 c2; do
echo "$c1"
echo "$c2"
done 3<crap 4<crap2
Upvotes: 1
Reputation: 7634
I believe paste
has the -d,--delimiter
option. So just do
paste -d '\n' /tmp/crap /tmp/crap2
assuming the cygwin paste
is similar to coreutils paste
or BSD paste
.
Upvotes: 3