For example, I might want to:
tail -f logfile | grep org.springframework | <command to remove first N characters>
I was thinking that tr
might have the ability to do this but I'm not sure.
For example, I might want to:
tail -f logfile | grep org.springframework | <command to remove first N characters>
I was thinking that tr
might have the ability to do this but I'm not sure.
You can use
cut
:-c:
charactersfile.txt:
input filenew_file.txt:
output fileN-:
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.
Use
cut
. Eg. to strip the first 4 characters of each line (i.e. start on the 5th char):I think
awk
would be the best tool for this as it can both filter and perform the necessary string manipulation functions on filtered lines:or
would remove the first 900 characters
cut
uses 900- to show the 900th character to the end of the linehowever when I pipe all of this through grep I don't get anything
Here is simple function, tested in bash. 1st param of function is string, 2nd param is number of characters to be stripped
function stringStripNCharsFromStart { echo ${1:$2:${#1}} }
Usage:
and you replace 5 by the number you want...it should do the trick...
EDIT if for each line
sed 's/^.\{5\}//g' logfile