LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Rename and *-operator (https://www.linuxquestions.org/questions/linux-software-2/rename-and-%2A-operator-173046/)

Nauguth 04-21-2004 06:21 PM

Rename and *-operator
 
Is it possible to use * sign at "rename -s" (or rename 's/\arg1/arg2/') arguments?

For example:

I have files test1_456, test2_776 and test3_487, and i want to strip the _-sign and everything that comes after that. Logically thinking command
Code:

rename -s '_*' '' test*
should do the trick, but it doesn't.

Is there some other way to do this, or have i just failed something?

blueser 04-22-2004 09:35 AM

I never used 'rename', and on Fedora it doesn't seem to have a '-s' option, but if it uses regexps, what you're saying with '_*' is '_ repeated 0 or more times', which is not what you want. Try using '_.*' instead (notice the '.' between '_' and '*' -- check grep's manpage for basic additional info on regexps).

HTH

Andre

Nauguth 04-22-2004 06:34 PM

I have somewhat modified version of rename. That -s operator is just supposed to do same stuff as 's/\//'-format, it just uses little easier syntax. It does not, however, use regexps, but thankfully 's/\//' does, and your advice worked perfectly for that.


All times are GMT -5. The time now is 06:24 PM.