I am trying to search the pattern "ARS (11)" and after the LAST pattern, i am trying to open new line and enter text using sed.
My Existing Text file is Users.txt
paul, Paul Smith, Stevn Smiley, REQ000001, ARS (11)
sam, Sam Martin, Stevn Smiley, REQ000001, ARS (11)
mike, Mike Conway, Stevn Smiley, REQ000001, ARS (11)
On Users.txt, I want the sed to Insert a New Line after the LAST "ARS (11)" pattern. In this case, fourth line is inserted by sed.
paul, Paul Smith, Stevn Smiley, REQ000001, ARS (11)
sam, Sam Martin, Stevn Smiley, REQ000001, ARS (11)
mike, Mike Conway, Stevn Smiley, REQ000001, ARS (11)
bob, Robert Hayward, Stevn Smiley, REQ000001, ARS (11)
I have tried the following command and however it is not working.
cat /root/projects/user_creations/Users.txt | tail -1 | while read line
do
#echo "$line" | sed -e '/ARS (11)/a\'$user''
echo "$line" | sed '/ARS (11)/a\"$user"'
done
:)