What is a unix command for deleting the first N characters of a line? What is a unix command for deleting the first N characters of a line? unix unix

What is a unix command for deleting the first N characters of a line?


Use cut. Eg. to strip the first 4 characters of each line (i.e. start on the 5th char):

tail -f logfile | grep org.springframework | cut -c 5-


sed 's/^.\{5\}//' logfile 

and you replace 5 by the number you want...it should do the trick...

EDITif for each line sed 's/^.\{5\}//g' logfile


You can use cut:

cut -c N- file.txt > new_file.txt

-c: characters

file.txt: input file

new_file.txt: output file

N-: Characters from N to end to be cut and output to the new file.

Can also have other args like: 'N' , 'N-M', '-M' meaning nth character, nth to mth character, first to mth character respectively.

This will perform the operation to each line of the input file.