Re: :t and getting senile.



On 2006-09-25, george.e.sullivan@xxxxxxxx wrote:
Ok, I know I am getting old. I can't remember where I saw this, but
how do you strip off the end of string such as a command line string so
that you just get the last part after the slash bar?

Ex: /here/there/everywhere/hello.

There was something I saw somewhere with a :t that would just give me
the hello part.

I don't know about :t (that may be something non-standard, such as
csh or zsh), but in a POSIX shell:

var=/here/there/everywhere/hello
base=${var##*/}

--
Chris F.A. Johnson, author <http://cfaj.freeshell.org/shell>
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
===== My code in this post, if any, assumes the POSIX locale
===== and is released under the GNU General Public Licence
.



Relevant Pages

  • Re: BASH help please??
    ... IFS= read var ... String length greater than width! ... command already has its stdin connected to a pipe. ... Shell Scripting Recipes: ...
    (comp.unix.shell)
  • Re: modify variable
    ... echo "$" ## remove trailing blah ... These can be combined to remove a string from the middle of a ... Shell Scripting Recipes: ...
    (comp.unix.shell)
  • Re: Bash: command output to variable
    ... Do you know why it kept giving errors? ... Variable type was wrong - ie it was expecting a string I think ... Have you considered allowing the use to exit? ... Shell Scripting Recipes: ...
    (comp.unix.shell)
  • Re: how to take each line from file as an input to a command
    ... then check for a string "is_valid" in a file with extension .per ... command is not going to be a number, so it can never -eq 0. ... echo "No Match found" ... Shell Scripting Recipes: ...
    (comp.unix.shell)
  • Re: quick sed question
    ... How do I strip the first two characters from the string, ... Shell Scripting Recipes: ...
    (uk.comp.os.linux)