Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8846795
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T12:05:26+00:00 2026-06-14T12:05:26+00:00

I am trying to create a script that replaces sub strings with an absolute

  • 0

I am trying to create a script that replaces sub strings with an absolute path, so I’m using

sed s/TEMPDIR/$PWD/ file.py > newfile.py

So obviously I want to replace TEMP with the absolute path, but I keep getting

sed: -e expression #1, char 12: unknown option to `s’

I think it might be because the path contains ‘/’, but I don’t know how to solve it. Any ideas?

Also, deos PWD guaranties an absolute path, given that I don’t deal with links?

Thanks!!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T12:05:27+00:00Added an answer on June 14, 2026 at 12:05 pm

    use a different delimiter:

    sed "s@TEMPDIR@$PWD@" file.py > newfile.py
    

    Using PWD probably does not guarantee an absolute path. (Depends on the shell). But pwd will return an absolute path, so use:

    sed "s@TEMPDIR@$(pwd)@" file.py > newfile.py
    

    Note that neither of these will work if your paths contain @. Pick a delimiter that does not appear in either. Note the following from the shell standard:

    In cases where PWD is set to the pathname that would be output by pwd -P, if there is insufficient permission on the current working directory, or on any parent of that directory, to determine what that pathname would be, the value of PWD is unspecified. Assignments to this variable may be ignored. If an application sets or unsets the value of PWD , the behaviors of the cd and pwd utilities are unspecified.

    So you can probably rely on $PWD. Note that neither pwd nor $PWD will resolve symbolic links, so you might prefer to use readlink -f .

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

im trying to create a script that opens a file and replace every 'hola'
I'm trying to create a script that takes a .txt file with multiple lines
Im trying to create a script that will post a notification stored in a
I'm trying to create simple script that subscribes a user to a company calendar.
I'm trying to create a script that will automatically select In Person Interview in
I am trying to create a script that finds the closest store/location to a
Hi I am trying to create a script that opens a variety of internet
I'm a newbie in php and Wordpress. I'm trying to create a script that
I'm trying to create a Python script that would : Look into the folder
I'm trying to create a shell script that shall convert certain Files according to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.