Shell scripting: enclose all lines with quotes








  • Using awk:
    awk '{print "\""$0"\""}' input.txt
    
    or if ignore empty lines:
    awk 'NF {print "\""$0"\""}' input.txt
    
  • Or using sed:
    sed -i.bak 's/^/"/; s/$/"/' input.txt
    
    or if ignore empty lines:
    sed -i.bak 's/^..*$/"&"/' input.txt
    



No comments:

Post a Comment