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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:32:53+00:00 2026-05-28T06:32:53+00:00

My intentions is to make all *.less files into style.css I am not very

  • 0

My intentions is to make all *.less files into style.css

I am not very familiar with this sed, however I have worked this out thanks to:
http://forums.devshed.com/unix-help-35/unix-find-and-replace-text-within-all-files-within-a-146179.html

for file in $(grep -rl ".less" *.php)
do
    sed -e "s/\/*.less/\/style.css/ig" $file > /tmp/tempfile.tmp
    mv /tmp/tempfile.tmp $file
done

Now this takes my files:

css/somefile.less
css/somefileagain.less
css/style.css
index.php

which is linked to in the php document

<link rel="stylesheet" type="text/css" href="css/somefile.less" />
<link rel="stylesheet" type="text/css" href="css/somefileagain.less" />

My result becomes

<link rel="stylesheet" type="text/css" href="css/somefile/style.css" />
<link rel="stylesheet" type="text/css" href="css/somefileagain/style.css" />

Which is not what I want. I want to get it to be the same path, and I think what I am missing is the * in the regexp which isn’t replaced by the sed. Is there any way to get that working, my try was to make it look like this: (and I want to replace everything from / to .less with /style.css)

\/*.less

And still that doesn’t work, maybe this approach is not the best, I need some advices if there is any flags that would replace the * as well, thanks.

Another issue I got is I cannot use -r/-R/–recursive in grep and I dont know why, I am running Debian. Any tips is appreciated.

/Marcus

  • 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-28T06:32:53+00:00Added an answer on May 28, 2026 at 6:32 am

    You need to use following sed command inside your for loop:

    sed -i.bak "s~/[^/]*\.less"~/style.css"~g" $file
    

    No need to store sed’s output in a separate file and then mv that temp file back to original. All this can be done with -i option.

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

Sidebar

Related Questions

1) Custom exceptions can help make your intentions clear. How can this be? The
So recursion is not my strong point, and I have been challenged to make
this might be a very simple question, but I could not find an answer
I have this snippet of code here. The intention is to make a copy
This is the code section from inno setup.My intention is to make two Checkbox
Hello dearest community, First of all, I hope my intention is not missconcept. I
Note: I have no intention of implementing this, it's more of a thought experiment.
I'm not very good at using complicated MySQL, so I'm stuck with a somewhat
first I have to admit this might be a pretty specific problem. In a
I have a very simple function which takes in a matching bitfield, a grid,

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.