Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.os.linux.misc > #30203

Re: I hate shell

From Jack Strangio <jackstrangio@yahoo.com>
Newsgroups comp.os.linux.misc
Subject Re: I hate shell
Date 2020-06-24 03:59 +0000
Organization North Star Horizon Builders Club
Message-ID <qCEw3I.1IC49@yahoo.com> (permalink)
References <rcrm4p$6p5$1@dont-email.me>

Show all headers | View raw


Rich <rich@example.invalid> writes:
> Jack Strangio <jackstrangio@yahoo.com> wrote:
>     "/home/test/with space/tail.e x t"
> 
> ../breakname "/home/test/with space/tail.e x t"
> 
You mean like this, without basename or dirname:


 breakname  "/home/test/with space/tail.e x t"
 
FNAME  (with extension)         = "tail.e x t"
FPATH  (sed)                = /home/test/with space
FNOEXT (without file extension) = tail
FEXT   (file extension alone)   = e x t
 
Reassembling our original CLI filename argument:
/home/test/with space/tail.e x t


================  breakname  ========================

#!/bin/bash
#
# breaks a filename into its path, basename-with-extension,
# basename-without-extension, file-extension alone
#

FN="$@"
echo " "

##################################################

FNAME=$(echo $FN | sed  "s/^.*\///g")
echo "FNAME  (with extension)         = $FNAME"


FPATH=$(echo $FN | sed "s/\/$FNAME//g")
echo "FPATH  (sed)                    = $FPATH"

FNOEXT=$(echo $FNAME | sed "s/\..*$//g" ) 
echo "FNOEXT (without file extension) = $FNOEXT"

#Note the filename and file extension can be extracted either with
# or without the '.' separator. Examples below we throw away the '.'

FEXT=$(echo $FNAME | sed "s/^.*\.//g")
echo "FEXT   (file extension alone)   = $FEXT"

#Note squiggly brackets purely to define a variable-name more clearly,
# as in was it '$FNOEXT' or '$FNOEXT.' that was specified?
 
#We reinsert our missing '.' and '/' if need be
echo " "
 echo "Reassembling our original CLI filename argument:"
echo $FPATH/${FNOEXT}.$FEXT
echo " "

=====================================================

Jack
-- 
"Those of you who think you know everything
 are pissing off those of us who do."

Back to comp.os.linux.misc | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

I hate shell The Natural Philosopher <tnp@invalid.invalid> - 2020-06-22 09:42 +0100
  Re: I hate shell Jack Strangio  <jackstrangio@yahoo.com> - 2020-06-22 14:01 +0000
    Re: I hate shell The Natural Philosopher <tnp@invalid.invalid> - 2020-06-22 17:05 +0100
      Re: I hate shell Grant Taylor <gtaylor@tnetconsulting.net> - 2020-06-22 10:23 -0600
        Re: I hate shell The Natural Philosopher <tnp@invalid.invalid> - 2020-06-22 18:48 +0100
      Re: I hate shell Robert Heller <heller@deepsoft.com> - 2020-06-22 11:32 -0500
      Re: I hate shell Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2020-06-22 12:41 -0400
        Re: I hate shell The Natural Philosopher <tnp@invalid.invalid> - 2020-06-22 18:49 +0100
      Re: I hate shell Jack Strangio  <jackstrangio@yahoo.com> - 2020-06-22 21:50 +0000
        Re: I hate shell The Natural Philosopher <tnp@invalid.invalid> - 2020-06-23 05:04 +0100
          Re: I hate shell Aragorn <thorongil@telenet.be> - 2020-06-23 10:15 +0200
            Re: I hate shell The Natural Philosopher <tnp@invalid.invalid> - 2020-06-23 09:38 +0100
              Re: I hate shell Aragorn <thorongil@telenet.be> - 2020-06-23 13:31 +0200
                Re: I hate shell The Natural Philosopher <tnp@invalid.invalid> - 2020-06-23 14:09 +0100
                Re: I hate shell Aragorn <thorongil@telenet.be> - 2020-06-23 15:58 +0200
                Re: I hate shell Harold Stevens <wookie@fossa.localdomain> - 2020-06-23 09:16 -0500
            Re: I hate shell Joe Beanfish <joebeanfish@nospam.duh> - 2020-06-23 14:17 +0000
              Re: I hate shell Aragorn <thorongil@telenet.be> - 2020-06-23 16:58 +0200
                Re: I hate shell Rich <rich@example.invalid> - 2020-06-23 16:47 +0000
                Re: I hate shell The Natural Philosopher <tnp@invalid.invalid> - 2020-06-23 19:13 +0100
                Re: I hate shell Joe Beanfish <joebeanfish@nospam.duh> - 2020-06-24 20:54 +0000
                Re: I hate shell gazelle@shell.xmission.com (Kenny McCormack) - 2020-06-24 23:24 +0000
      Re: I hate shell Jack Strangio  <jackstrangio@yahoo.com> - 2020-06-22 23:11 +0000
        Re: I hate shell Rich <rich@example.invalid> - 2020-06-23 01:33 +0000
          Re: I hate shell The Natural Philosopher <tnp@invalid.invalid> - 2020-06-23 05:07 +0100
          Re: I hate shell Jack Strangio  <jackstrangio@yahoo.com> - 2020-06-24 03:59 +0000
        Re: I hate shell The Natural Philosopher <tnp@invalid.invalid> - 2020-06-23 05:05 +0100
      Re: I hate shell Eli the Bearded <*@eli.users.panix.com> - 2020-06-23 18:41 +0000
    Re: I hate shell "Anonymous Remailer (austria)" <mixmaster@remailer.privacy.at> - 2020-06-23 11:12 +0200
  Re: I hate shell Rathbone <please@replytolist.com> - 2020-06-22 20:22 +0000
    Re: I hate shell Aragorn <thorongil@telenet.be> - 2020-06-23 10:20 +0200
      Re: I hate shell The Natural Philosopher <tnp@invalid.invalid> - 2020-06-23 09:41 +0100
        Re: I hate shell Aragorn <thorongil@telenet.be> - 2020-06-23 13:32 +0200

csiph-web