linux shell编程读写文件
#!/bin/sh
cat first|while read LINE
do
str="$LINE majk"
echo $str
echo $str >>
copyreadfile.txt
done
2#
如何用shell脚本读取文件的内容
我有个abc.txt文件,里面内容如下:
BKLJLK76.doc
98JKL897.DOC
87JLJLJH6.xls
……
……
有很多行,需要一个脚本实现对abc.txt逐行读取,然后分别从系统的/old目录下查找出来并移动到/new目录下。
3#
#!/bin/sh
for i in `cat abc.txt`
do
copy -f /old/$i /new &> /dev/null
done
4#
shell:读取文件的每一行内容并输出 [linux编程]
写法一:
----------------------------------------------------------------------------
#!/bin/bash
while read line
do
echo $line
done < file(待读取的文件)
----------------------------------------------------------------------------
写法二:
----------------------------------------------------------------------------
#!/bin/bash
cat file(待读取的文件) | while read line
do
echo $line
done
----------------------------------------------------------------------------
写法三:
----------------------------------------------------------------------------
for line in `cat file(待读取的文件)`
do
echo $line
done
----------------------------------------------------------------------------
done
2#
如何用shell脚本读取文件的内容
我有个abc.txt文件,里面内容如下:
BKLJLK76.doc
98JKL897.DOC
87JLJLJH6.xls
……
……
有很多行,需要一个脚本实现对abc.txt逐行读取,然后分别从系统的/old目录下查找出来并移动到/new目录下。
3#
#!/bin/sh
for i in `cat abc.txt`
do
copy -f /old/$i /new &> /dev/null
done
4#
shell:读取文件的每一行内容并输出 [linux编程]
写法一:
----------------------------------------------------------------------------
#!/bin/bash
while read line
do
echo $line
done < file(待读取的文件)
----------------------------------------------------------------------------
写法二:
----------------------------------------------------------------------------
#!/bin/bash
cat file(待读取的文件) | while read line
do
echo $line
done
----------------------------------------------------------------------------
写法三:
----------------------------------------------------------------------------
for line in `cat file(待读取的文件)`
do
echo $line
done
----------------------------------------------------------------------------