On Sun, 22 Oct 2023 16:33:12 +0000
Albretch Mueller <lbrt...@gmail.com> 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

Bash has built in operators to extract this sort of thing. Greg
Wooledge will know what they are called. Something like:

fspec="/exp/home1/abc.txt" 
filename="${fspec##*/}"  # get filename
dirname="${fspec%/*}" # get directory/path name

That doesn't do exactly what you want, but comes close.

-- 
Does anybody read signatures any more?

https://charlescurley.com
https://charlescurley.com/blog/

Reply via email to