Skip to content
Advertisement

How to remove some string with awk/sed or another command in linux?

I want to ask, how I can remove some string with command in linux?

JavaScript

and the output:

JavaScript

Advertisement

Answer

try:

JavaScript

Making field separator as | then substituting the starting zeros with NULL of 111th field as per your requirements, mentioning 1 will print the newly edited line(if any zeros were replaced with NULL), setting Output field separator as | and mentioning the Input_file then.

EDIT: Adding 2nd solution for removing -000 into 11th field as follows.

JavaScript

Here I am making | as field separator then substituting the starting zeros in 11th field with NULL and then substituting the -0+ means from -0 till all the zeros to NULL too here and then 1 will print the lines. Setting Output field separator as | too.

Advertisement