I have flat file with data as
cast ( (emp_ID) as varchar(2000) ),
cast ( (emp_name) as varchar(2000) ),
I want to remove the , from the last line in this file. The output should be:
cast ( (emp_ID) as varchar(2000) ),
cast ( (emp_name) as varchar(2000) )
I am using the following command:
tail -1 select_stmnt.txt | sed 's/,/''/g' >> select_stmnt.txt
What I get is:
cast ( (emp_ID) as varchar(2000) ),
cast ( (emp_name) as varchar(2000) ),
cast ( (emp_name) as varchar(2000) )
Removal of the , is working fine, but instead of the modified line replacing the original, it is appended, which I don't want.
You can try this:
The first dollar($) will be used to select the last line.