2 Replies Latest reply on Feb 17, 2015 8:51 PM by Santhosh Kurimilla

    sed commands on NSH

    Santhosh Kurimilla



      When I tried to run sed command through NSH, I receive below error message. The same command works just fine when I tried on BASH shell. Any idea if I am missing anything here?


      ServerXYZ# sed -i "s/231/226/g" disk_cleanup.sh

      sed: 1: "disk_cleanup.sh": extra characters at the end of d command


      # sed -i "s/231/226/g" disk_cleanup.sh

      # ls -l disk_cleanup.sh

      -rwxr--r-- 1 bladmin bladmin 878 Feb 16 04:22 disk_cleanup.sh

        • 1. Re: sed commands on NSH
          Bill Robinson

          nsh does not use the gnu sed so the arguments are different.  i'm assuming you are using the gnu sed there.  check the man page for sed in nsh and what you need to supply to the -i argument.

          1 of 1 people found this helpful
          • 2. Re: sed commands on NSH
            Santhosh Kurimilla

            Yes Bill, I read the man page seperately on NSH and BASH.


            sed -i on NSH:

                   -i extension

                           Edit  files  in-place similarly to -I, but treat each file independently from other files.

                           In particular, line numbers in each file start at 1, the "$" address matches the last line

                           of  the  current  file,  and  address  ranges  are  limited to the current file.  (See Sed

                           Addresses.)  The net result is as though each file were edited by a separate sed instance.


            sed -i on BASH:

                  -i[SUFFIX], --in-place[=SUFFIX]

                          edit files in place (makes backup if extension supplied)


            It seems, sed on NSH requires an extension for a backup. It worked fine for me after I added extension to -i.


            ServerXYZ# sed -i bkp "s/226/231/g" disk_cleanup.sh

            ServerXYZ# ls -l disk_cleanup*

            -rw-r--r--   1 bladmin  bladmin       892 Feb 17 21:44 disk_cleanup.sh

            -rwxr--r--   1 bladmin  bladmin       892 Feb 17 00:29 disk_cleanup.shbkp


            Thank you, Bill.!