sed with literal string--not input file

前端 未结 3 783
-上瘾入骨i
-上瘾入骨i 2020-12-12 23:09

This should be easy: I want to run sed against a literal string, not an input file. If you wonder why, it is to, for example edit values stored in variabl

3条回答
  •  无人及你
    2020-12-12 23:41

    My version using variables in a bash script:

    Find any backslashes and replace with forward slashes:

    input="This has a backslash \\"
    
    output=$(echo "$input" | sed 's,\\,/,g')
    
    echo "$output"
    

提交回复
热议问题