It is currently Tue, 07 Dec 2021 02:42:53 GMT



 
Author Message
 How to find if the last line ends with a specified word
Hi all,
Can you please help me... I require this :
I have written a script which accepts the file name, host, path etc as
arguments and invokes the FTP. I need to do a validation on the path.
THe path should end with \inbound. If the path ends with
\user\tmpFolder reject it, if it ends with \user\inbound then OK,
proceed.
How do I check it? I read the 'man cut', but I guess it accepts
fileName to look, cant send a line, for e.g 'cut -f fileName' and not
'cut -f line'

Any help will be of immense use.
Thanks,
V.K.Nair



 Sun, 01 May 2005 07:14:02 GMT   
 How to find if the last line ends with a specified word

news:f0dde875.0211121514.3380f1c4@posting.google.com...

Have you looked at the man page for basename(1)?

--
Fletcher Glenn
to reply remove NOSPAM from my reply address



 Sun, 01 May 2005 07:20:34 GMT   
 How to find if the last line ends with a specified word

What kind of Unix pathname looks like that?



 Sun, 01 May 2005 07:31:09 GMT   
 How to find if the last line ends with a specified word

        case $path in
            */inbound) echo OK ;; ## I assume you meant "/" not "\"
            */user/tmpFolder) echo Rejected ;;
            *) ;; ## etc....
        esac

--
    Chris F.A. Johnson                        http://cfaj.freeshell.org
    ===================================================================
    My code (if any) in this post is copyright 2002, Chris F.A. Johnson
    and may be copied under the terms of the GNU General Public License



 Sun, 01 May 2005 09:27:58 GMT   
 How to find if the last line ends with a specified word
Is there a unix system has such path???
anyway after getting the input from user,
cant you use echo $path|grep inbound$


 Sun, 01 May 2005 15:01:57 GMT   
 How to find if the last line ends with a specified word
This is how I did it. It works (as of now). I do not know if this the
simplest way..... I feel i am going the long way....anyway....
#LOCAL_DIR is the argument that has the path
#isInbound  is the variable that would hold the last word.

isInbound=`echo "$LOCAL_DIR" | tail -c 8`

if [ $COMMAND = mget ] || [ $COMMAND = get ]
then
        if [ $isInbound = 'inbound' ]
        then
                echo 'Yes! folder was inbound'
        else
                echo No! it was not inbound
                echo 'FTP Failed: Invalid folder for Inbound- ' $LOCAL_DIR >
$LOCAL_DIR'/'output.txt
                mailx -s 'FTP Failed' ${EMAIL_TO}  < $LOCAL_DIR'/'output.txt
                exit 0
        fi
fi

Any comments on the above code would be extremely helpful.
Thanks guys for helping me out with your thoughts.

V.K. Nair.

"Chris F.A. Johnson" <c.f.a.john...@rogers.com> wrote in message <news:aqs9qu$crjod$1@ID-136730.news.dfncis.de>...



 Wed, 04 May 2005 06:36:09 GMT   
 How to find if the last line ends with a specified word

[please don't top post]

- Show quoted text -

   case $COMMAND in
      mget|get)
         case $LOCAL_DIR in
            *inbound) echo 'Yes! folder was inbound' ;;
            *) echo No! it was not inbound
               echo 'FTP Failed: Invalid folder for Inbound- ' $LOCAL_DIR > $LOCAL_DIR/output.txt
               mailx -s 'FTP Failed' ${EMAIL_TO}  < $LOCAL_DIR/output.txt
               exit 0
               ;;
         esac
      ;;
   esac

--
    Chris F.A. Johnson                        http://cfaj.freeshell.org
    ===================================================================
    My code (if any) in this post is copyright 2002, Chris F.A. Johnson
    and may be copied under the terms of the GNU General Public License



 Wed, 04 May 2005 07:04:20 GMT   
 
   [ 7 post ] 

Similar Threads

1. How to find the last line that contains a word in file

2. find files last modified on specified date

3. Grep for word at end of line?

4. get last word of a line

5. sed: last line is omitted if no \n at the end of file

6. How to find the first readable word in one line

7. finding last line of files ...

8. awk-outputting input lines on specified line number


 
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software