Options

Question about linux rename command

JerryLJerryL Member Posts: 96 ■■■□□□□□□□
I realize that this is a very basic question, but i'm stuck about the syntax on the rename command. I understand the command syntax except for one thing in it. The syntax is rename 's/OLD/NEW' FILES. My question (and i can't find the answer anywhere) is what does the "s" represent in the command?

A simple question, but bugging me because i can't seem to find a meaning for what the "s" stands for. If any one knows, please let me know.


Thanks.

A newbie to linux.

Comments

  • Options
    NovaHaxNovaHax Member Posts: 502 ■■■■□□□□□□
    Wish I could help. I always just use 'mv'
  • Options
    JerryLJerryL Member Posts: 96 ■■■□□□□□□□
    Thanks for the reply. From what i understand, the differences between mv and rename are that mv is used to usually move or rename single files. Rename is used to rename multiple or groups of files.
  • Options
    devils_haircutdevils_haircut Member Posts: 284 ■■■□□□□□□□
    I believe the 's' comes from Perl syntax, which is way beyond anything I know.
  • Options
    BokehBokeh Member Posts: 1,636 ■■■■■■■□□□
  • Options
    TBev0TBev0 Member Posts: 23 ■□□□□□□□□□
    I also usually use the mv command, however my guess would be that the "s" stands substitute, as the syntax is similar to the sed command.
  • Options
    JerryLJerryL Member Posts: 96 ■■■□□□□□□□
    Wow. That is buried down. I thought that this would be a very simple question. From what i can figure out from the link that Bokeh gave, it means "search and replace". If that's the case, it makes sense because renaming file(s) is really searching them out and replacing them. Now that i have the full syntax broken down, it actually makes more sense. At least with me, if I understand the syntax, then that is more than half the battle.

    Thanks everyone from a linux newbie who's just at the beginning of the path.
  • Options
    ratbuddyratbuddy Member Posts: 665
    S stands for substitute, and it goes back way farther than Perl. sed (do you capitalize an uncapitalized proper noun at the beginning of a sentence?) and vi can both use forms of s/whatever/whatever, and they were written in the 1970s :)
  • Options
    JerryLJerryL Member Posts: 96 ■■■□□□□□□□
    Hmmm. Thanks for the update. I stand corrected. Either way, once you learn the full meaning of the syntax, things fall into place. At least for me they do.
  • Options
    prampram Member Posts: 171
    Useless unix history here, but it goes back even further than sed! It came from ed (sed is a non-interactive derivative of ed) which was written by the father of unix himself, Ken Thompson.
  • Options
    devils_haircutdevils_haircut Member Posts: 284 ■■■□□□□□□□
    The more you know...
  • Options
    JerryLJerryL Member Posts: 96 ■■■□□□□□□□
    Scary thought... I might actually learn something through this. Thanks guys for the help on this. I'm sure that there will be more questions coming along. icon_study.gif
Sign In or Register to comment.