I've been trying to manipulate a single line in a file without much success.
test.txt
10.20.30.40 "User 1" 73.15.16.24 NewUser 124.18.21.17 "User 2" 27.76.58.248 "User 3" 39.16.87.227 "User 4" 211.129.20.52 "User 5" 175.15.118.110 "User 6"
If you notice the second line doesn't have quotes around the last word. I have been trying to figure out a way to put quotes around that and save it, either in another file, or preferably in the original.
When I used this command:
cat test.txt | grep -v '".*"' | sed -i 's/\([A-Z]\)/"\1/g'
It finds the correct line and places a quote at the beginning of the word, but then puts another before the U, which isn't what I need. I could always use sed to place a quote at the last position of course, but it would be nice to encompass the entire word.
If I then use the sed command with the -i and point it to the original file, it then throws quotes around every word when saved, which is also what I'm not wanting.
Any help is appreciated, I've been trying to solve this for a couple of days now.