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 7660919
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T13:31:48+00:00 2026-05-31T13:31:48+00:00

I have a file and want to replace a pattern with another string. #PBS

  • 0

I have a file and want to replace a pattern with another string.

#PBS -N bench1-M1-plt2-size15
#PBS -o /home/results/bench1-M1-plt2-size15.out
./run -d ./results/ --config=bench1-M1-plt2-size15.conf \ 
--results=bench1-M1-plt2-size15.res config/myConfig.txt -F 2000000 

I use this command

sed 's/M1-[^-]*-[^-]/M1-plt32-size10/g' filename

However the output file looks like this:

#PBS -N M1-plt32-size100
#PBS -o /home/mahmood/gem5/results/M1-plt32-size100.out
./run -d ./results/ --config=bench1-M1-plt32-size100.conf \
--results=bench1-M1-plt32-size100.res config/myConfig.txt -F 2000000 

Please note an extra ‘0’ character after “size10”. As you can see, in the SED command, size is set to 10, however the output file is “size100”

What is the problem and how can I fix that?

  • 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-05-31T13:31:49+00:00Added an answer on May 31, 2026 at 1:31 pm

    Your regex is not correct. You have [^-] which will match only 1 non-hyphen character. I believe this is what you intended:

    sed 's/M1-[^-]*-[^\.]*/M1-plt32-size10/' filename
    

    OUTPUT:

    #PBS -N bench1-M1-plt32-size10
    #PBS -o /home/results/bench1-M1-plt32-size10.out
    ./run -d ./results/ --config=bench1-M1-plt32-size10.conf \ 
    --results=bench1-M1-plt32-size10.res config/myConfig.txt -F 2000000
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

HI, I have some string from XML file, and I I want to replace
I have the local file path as c:\new folder\pdf\today\k.pdf I want to replace the
I have a file config.ini with the following contents: @ndbd I want to replace
I have an html file and I want to replace the empty paragraphs with
I have a file on which I want to replace the dates but I
I have a binary file and i want to replace the value A2 at
I have a file r . I want to replace the words File and
I have a file that I want to include in Python but the included
I have a file that I want to read in using the File::Slurp module
I have a large file I want to download from a server I have

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.