如何使用 cut 从字符串中删除所有单个字符
How to get rid of all of a single character from a string with cut
我正试图摆脱所有的“|”字符并从格式如下的输入文件中添加 space:
单词|单词|数字
F=$(curl ftp://ip/pub/text.txt)
cut_stuff(){
# this is where I get confused
cut -d"|" -f "1-3"
}
for i in $F; do
echo $i | cut_stuff
done
根据要求,使用 cut
:
$ echo 1\|2\|3 | cut -d \| --output-delimiter=" " -f 1-
1 2 3
我正试图摆脱所有的“|”字符并从格式如下的输入文件中添加 space: 单词|单词|数字
F=$(curl ftp://ip/pub/text.txt)
cut_stuff(){
# this is where I get confused
cut -d"|" -f "1-3"
}
for i in $F; do
echo $i | cut_stuff
done
根据要求,使用 cut
:
$ echo 1\|2\|3 | cut -d \| --output-delimiter=" " -f 1-
1 2 3