On Sun, Oct 22, 2023 at 04:33:12PM +0000, Albretch Mueller wrote: > After generating a file with lines of text, I have to: > 1) parse some of those lines based on a pattern I know (no regex > necessary, just a FS path) > 2) once parsed from those lines I need the last n characters only > I am trying to use a one liner like: > cat "${IFL}" | grep "${DESC_DIR}" | tail -c+$_DESC_DIR > but this one liner repeats the output and the tail > The way that -c operates for tail is based on 'each file' provided as input:
-c, --bytes=[+]NUM output the last NUM bytes; or use -c +NUM to output starting with byte NUM of each file However, when piping input in the way you are above, the entire output of grep is taken as one file and fed into the input of tail. You could instead loop over the lines coming out of grep, but that feels somewhat ugly. Essentially, your pipeline probably needs to be something more like this: sed -r -e "s+.*${DESC_DIR}++" "${IFL}" | tail Or drop the tail entirely if what you really want is the last part of each line, regardless of how many there are. Regards, -Roberto -- Roberto C. Sánchez