bash, extract string before a colon

前端 未结 5 994
暖寄归人
暖寄归人 2020-12-23 01:56

If I have a file with rows like this

/some/random/file.csv:some string
/some/random/file2.csv:some string2

Is there some way to get a file

5条回答
  •  甜味超标
    2020-12-23 02:27

    Another pure Bash solution:

    while IFS=':' read a b ; do
      echo "$a"
    done < "$infile" > "$outfile"
    

提交回复
热议问题