Shell脚本:读取文件中的行 [英] Shell Script: Read line in file

查看:131
本文介绍了Shell脚本:读取文件中的行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个文件 paths.txt

/my/path/Origin/.:your/path/Destiny/.
/my/path/Origin2/.:your/path/Destiny2/.
/...
/...

我需要脚本 CopyPaste.sh 使用文件path.txt将OriginX中的所有文件复制到DestinyX

I need a Script CopyPaste.sh using file paths.txt to copy all files in OriginX to DestinyX

类似的事情:

 #!/bin/sh

while read line
do
        var= $line | cut --d=":" -f1
        car= $line | cut --d=":" -f2
        cp -r var car

done < "paths.txt"


推荐答案

使用翻译: tr 命令&

Use translate : tr command & apply cp command in the same go!

#!/bin/sh

while read line; do
  cp `echo $line | tr ':' ' '`
done < "paths.txt"

这篇关于Shell脚本:读取文件中的行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆