Sponsored Content
Top Forums Shell Programming and Scripting sed not working properly with slash / Post 303023918 by MadeInGermany on Tuesday 25th of September 2018 02:37:25 PM
Old 09-25-2018
You can do this with bash builtins:
Code:
# read a line into words[0...n]
while read -a words
do
  if [ "${words[0]}" = "put" ]
  then
    wrd=${words[1]}
    # split $wrd on the rightmost "/"
    dir=${wrd%/*}
    file=${wrd##*/}
    # if there were no "/" then $dir==$wrd and $wrd==$file
    if [ "$dir" != "$wrd" ]
    then
      echo "cd $dir"
      words[1]=$file
    fi
  fi
  echo "${words[@]}"
done

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Keyboard not working properly...

Hello Again, Those that have noticed my earlier posts will know that I have succesfully installed Solaris 8 onto my pc. I haven't been able to get x-server working (i think it doesn't like my video card) though I've been able to log into root (with a bit of help from unix forums :o ) and have... (2 Replies)
Discussion started by: timresh
2 Replies

2. Programming

y is this not working properly?

#include <stdio.h> #include <sys/types.h> #include <string.h> #include <sys/stat.h> #include <unistd.h> struct stat s; main() { char c; if (fork()==0) { system("clear"); do { printf("myAI\\>§ "); scanf("%s",c); if(stat(c,&s)>-1) {... (3 Replies)
Discussion started by: C|[anti-trust]
3 Replies

3. UNIX for Dummies Questions & Answers

Telnet is not working properly

telnet at my system is behaving stange. Some times I am able to telnet to other machines but sometimes it stop doing that. Then i have to reboot the machine and most of the time (not 100%) it works. SImilar is the case with SSH. Sometime it works , some time it don't. i am new to Unix and I do not... (1 Reply)
Discussion started by: deepak_pathania
1 Replies

4. HP-UX

Cron - Not working properly

Hi, I do have three scripts. Whcih inserts records into a table using sqlldr, creating some reprot files etc. The first script will call the second and then the second will call the third. When I run my first script from the shell prompt, all my operation are completed successfully. If I do... (23 Replies)
Discussion started by: risshanth
23 Replies

5. Shell Programming and Scripting

\n not working properly

Hi all, I'm trying to generate a series of txt files starting from a plain csv file part of my code: #!/bin/ksh INSTALLDIR=/Users/ME/Installdir CSV=CSV.csv TMP=/tmp/$(basename $0).txt tr -s "\r" "\n" < /$INSTALLDIR/$CSV > $TMP function Makefiles { printf '%24s:%30s\n' "sometext"... (1 Reply)
Discussion started by: Jive Spector
1 Replies

6. UNIX for Advanced & Expert Users

Sendmail is not working properly

Hi All, Can any one help me to solve the issue. The Issue is, i have started the sendmail service on my RHEL 4 update 6 box, I am able to send the mail from my box to almost all of the Email Id's except few. Exampe, test mail. . Output is :the message is sent. now if I send the... (2 Replies)
Discussion started by: akhtar.bhat
2 Replies

7. Shell Programming and Scripting

Using sed to append backward slash before forward slash

Hi all, I need to know way of inserting backward slash before forward slash. My problem is that i need to supply directory path as an argument while invoking cshell script. This argument is further used in script (i.e. sed is used to insert this path in some file). So i need to place \ in front... (2 Replies)
Discussion started by: sarbjit
2 Replies

8. Shell Programming and Scripting

mailx not working properly

I am using mailx command in my script to attach a file and send an email. I need to attach a csv file and send email to a mail id - I am using uuencode output.csv output.csv | mailx -s "test mail" xyz@abc.com This will send a mail with scrambled text in body. am i missing something ?... (4 Replies)
Discussion started by: Sriranga
4 Replies

9. Shell Programming and Scripting

Sed script not working properly on Solaris (works fine on AIX)?

Hi, I have a problem with a SED script that works fine on AIX but does not work properly on a Solaris system. The ksh script executes the SED and puts the output in HTML in tables. But the layout of the output in HTML is not shown correctly(no tables, no color). Can anyone tell if there is... (7 Replies)
Discussion started by: Faith111
7 Replies

10. UNIX for Beginners Questions & Answers

sed command not working properly

This is my sample file cat bipin.txt Unix is an OS Unix has its own commmands Unix is a user friendly OS Unix is platform independent Unix is a time sharing OS the best OS to learn is Unix Abinitio uses Unix in backend When i use sed 's/Unix/Linux/' bipin.txt , only the first... (2 Replies)
Discussion started by: Bipin_1991
2 Replies
american-english-small(5)					   Users' Manual					 american-english-small(5)

NAME
american-english-small - a list of English words DESCRIPTION
/usr/share/dict/american-english-small is an ASCII file which contains an alphabetic list of words, one per line. FILES
There may be any number of word lists in /usr/share/dict/. /etc/dictionaries-common/words is a symbolic link to the currently-chosen /usr/share/dict/<language> file. /usr/share/dict/words is a symbolic link to /etc/dictionaries-common/words, and is the name by which other software should refer to the system word list. See select-default-wordlist(8) for more information, and/or to change the currently- chosen word list. The directory /usr/share/dict can contain word lists for many languages, with name of the language in English, e.g., /usr/share/dict/french and /usr/share/dict/danish contain respectively lists of French and Danish words if they exist. Such lists should be coded using the ISO 8859-1 character set encoding. SEE ALSO
ispell(1), select-default-wordlist(8), and the Filesystem Hierarchy Standard. HISTORY
The words lists are not specific, and may be generated from any number of sources. The system word list used to be /usr/dict/words. For compatibility, software should check that location if /usr/share/dict/words does not exist. AUTHOR
Word lists are collected and maintained by various authors. The Debian English word lists are built from the SCOWL (Spell- Checker Ori- ented Word Lists) package, whose upstream editor is Kevin Atkinson <kevina@users.sourceforge.net>. Debian 16 June 2003 american-english-small(5)
All times are GMT -4. The time now is 12:34 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy