Help needed in scripting

Hi Guys,

I need help in scripting out the below :

this is a sample data i have in my file:

jobname type 8:00:00 AM

I need to remove the ":00" from the time field alone.

Thanks in advance for all ur help

sed 's/:00//g'  <filename> 

should help

Hi,

I missed one thing i need to replace only the ":00" in the seconds column alone

Thanks

In awk set the FS to ":" and then substitute the $3 field.

cat filename | awk -F ":" '{print $1":"$2":"$3}' >>new.file

replace $3 with your requirement in ""

cat filename | awk -F ":" '{print $1":"$2 ", substr($3,3)}' >>new.file

will give the required result

Hi isubodh,

The command u gave is thowing an error

awk: {print $1":"$2 " substr($3,2)}
awk: ^ unterminated string

Remove the third double quote:

awk: {print $1":"$2 " substr($3,2)}
1 Like
cat filename | awk -F ":" '{print $1":"$2, substr($3,3)}' >>new.file