- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- problem with sed command
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-04-2006 06:46 PM - last edited on 01-13-2013 08:26 PM by Cathy_xu
05-04-2006 06:46 PM - last edited on 01-13-2013 08:26 PM by Cathy_xu
problem with sed command
I am facing the problem with the sed on my server.
My requirement is to change the filename in the ssort and awk scripts to point to the correct directory. To change the directory I need to delimit the “/” so as to have it “\/” in the variable to be successful with the sed.
The limitation with the ssort is it will not accept the second occurrence of the /INFILE as a variable (like /INFILE $1)
So we have to use the sed to replace the FILE_NAME after the /INFILE to point to the correct directory.
At the time of testing the sed is giving the problem.
It is successful with the command (2), but with the tilda(`) to assign it to variable it is giving the below error, command (3).
1) $ FINAL_MANUF=/apps/aloyan/loading/data;export FINAL_MANUF
2) $ echo $FINAL_MANUF|sed 's/\//\\\//g'
\/apps\/aloyan\/loading\/data
3) $ UPC_REJECT=`echo /OPT/LOYAN/LOADING/DATA_TEMP/UPC_REJECT|sed 's/\//\\\//g'`
sed: Function s/\//\\//g cannot be parsed.
is it a problem with the sed?
i tried with "sed" command with its full path "/usr/bin/sed", still I am getting the same error:
sed: Function s/\//\\//g cannot be parsed.
please suggest
P.S.This thread has been moved from HP-UX>System Administration to HP-UX > langages- HP Forums Moderator
- Tags:
- sed
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-04-2006 06:54 PM
05-04-2006 06:54 PM
Re: problem with sed command
echo "/apps/aloyan/loading/data" | tr '\/' '\\' gives
\apps\aloyan\loading\data
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-04-2006 06:57 PM
05-04-2006 06:57 PM
Re: problem with sed command
Why not this,
#echo "/apps/aloyan/loading/data" |sed 's/\/\\//g'
/apps/aloyan/loading/data
-Arun
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-04-2006 07:03 PM
05-04-2006 07:03 PM
Re: problem with sed command
$ echo $FINAL_MANUF|sed 's/\//\\/g'
\apps\aloyan\loading\data
$ UPC_REJECT=`echo /OPT/LOYAN/LOADING/DATA_TEMP/UPC_REJECT|sed 's/\//\\\/g'`
$ echo $UPC_REJECT
\OPT\LOYAN\LOADING\DATA_TEMP\UPC_REJECT
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-04-2006 07:38 PM
05-04-2006 07:38 PM
Re: problem with sed command
how to resolve this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-04-2006 07:51 PM
05-04-2006 07:51 PM
Re: problem with sed command
This is a script problem with usage of sed. Not a problem with "sed".
-Arun
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-04-2006 07:57 PM
05-04-2006 07:57 PM
Re: problem with sed command
your escapes via \ mus be doubled, if processing of the string is doubled:
in a plain echo '\\', in an execution in `` you have to use '\\\\'. As a side effect, echo may recognize character special sequences ('\n') you not intend to be performed.
You can do this assignment nearly without esacaping:
echo /OPT/LOYAN/LOADING/DATA_TEMP/UPC_REJECT|sed 's:/:\\:g' | read UPC_REJECT
mfG Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-04-2006 09:06 PM
05-04-2006 09:06 PM
Re: problem with sed command
I am able to get the correct output when i use the command on $ sign.
but when i create a script with the same command, it is giving the error.
sed: Function s/\//\\//g cannot be parsed.
i have changed this file permission to 777
please suggest what to do.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-04-2006 09:09 PM
05-04-2006 09:09 PM
Re: problem with sed command
using my approach in a script (ksh, posix-shell) worked for me - which shell do you use in your script?
mfG Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-04-2006 09:11 PM
05-04-2006 09:11 PM