我有两个文件。一个文件名为空格,另一个文件的空格已被强大而强大的tr命令替换为underbar。
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我想让输出像这样显示到文件,使之显示--一种是用酒吧显示的,另一种是用非酒吧显示的:
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但是,当我将bash命令与while循环和嵌套的for循环一起使用时,输出就会非常混乱:
$ 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我尝试过使用其他脚本更改IFS,然后创建不同的cat文件,现在我所做的是
paste /tmp/crap /tmp/crap2 两个文件,并使用vi进行编辑。
发布于 2015-04-05 13:51:28
使用2个文件描述符:
while read -u3 c1 && read -u4 c2; do
echo "$c1"
echo "$c2"
done 3<crap 4<crap2发布于 2015-04-05 05:14:44
我相信paste有-d,--delimiter选项。所以就这么做吧
paste -d '\n' /tmp/crap /tmp/crap2假设cygwin paste类似于coreutils、paste或BSD paste。
https://stackoverflow.com/questions/29454293
复制相似问题