作者热门文章
- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我有一个包含文件路径的文件。像这样:
C:\Users\peter\workspace\etwas.txt
我试着用这个例程阅读
while read LINE
do
web=$LINE
echo $web
done <etwas.txt
结果:
C:Userspeterworkspaceetwas.txt
我将以这种形式阅读
C:/Users/peter/workspace/etwas.txt
如何阅读?
最佳答案
尝试只使用 bash 内建函数:
while read -r LINE; do
web="${LINE//\\//}"
echo "$web"
done < etwas.txt
$ cat etwas.txt
C:\Users\peter\workspace\etwas.txt
$ while read -r LINE; do
> web="${LINE//\\//}"
> echo "$web"
> done < etwas.txt
C:/Users/peter/workspace/etwas.txt
我使用 bash parameter expansion将 \
替换为 /
关于linux - bash replace\with/in 一个 tetxfile,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15056145/
我有一个包含文件路径的文件。像这样: C:\Users\peter\workspace\etwas.txt 我试着用这个例程阅读 while read LINE do web=$LINE ec
我是一名优秀的程序员,十分优秀!