LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-18-2011, 01:30 PM   #1
lynne007
LQ Newbie
 
Registered: Jul 2010
Location: usa
Posts: 10

Rep: Reputation: 0
how to tell if "rename" in your distro supports regular expressions


I am trying to do a rename using a regular expression, and it doesn't seem to work.

I did a web scan, and it looks like some versions of linux don't support regular expressions for commands. How do I tell if a version of linux supports regular expressions?

for that matter, how do I tell what version of linux I am using?
 
Old 01-18-2011, 01:49 PM   #2
tsg
Member
 
Registered: Mar 2008
Posts: 155

Rep: Reputation: 30
Quote:
Originally Posted by lynne007 View Post
for that matter, how do I tell what version of linux I am using?
Code:
uname -r
 
Old 01-18-2011, 01:57 PM   #3
lynne007
LQ Newbie
 
Registered: Jul 2010
Location: usa
Posts: 10

Original Poster
Rep: Reputation: 0
I get:
2.6.18-194.26.1.el5

how do I tell if that version of linux supports regular expressions in the commands?
 
Old 01-18-2011, 02:02 PM   #4
markush
Senior Member
 
Registered: Apr 2007
Location: Germany
Distribution: Slackware
Posts: 3,979

Rep: Reputation: 850Reputation: 850Reputation: 850Reputation: 850Reputation: 850Reputation: 850Reputation: 850
Hi lynne007,

could you please explain what you want to do? I don't understand your question.

Linux is the kernel.

There are many programs/commands which support regular expressions.

But the kernel and the programs are different things.

Markus
 
1 members found this post helpful.
Old 01-18-2011, 02:03 PM   #5
stress_junkie
Senior Member
 
Registered: Dec 2005
Location: Massachusetts, USA
Distribution: Ubuntu 10.04 and CentOS 5.5
Posts: 3,873

Rep: Reputation: 332Reputation: 332Reputation: 332Reputation: 332
Quote:
Originally Posted by lynne007 View Post
2.6.18-194.26.1.el5
how do I tell if that version of linux supports regular expressions in the commands?
The name of the kernel suggests (to me) that you are either using Red Hat or Centos. Those certainly do support regular expressions. I have never heard of any distribution that does not support regular expressions. Perhaps you are confusing that term with something else.

We could provide better information if you described your problem in greater detail. What exactly are you trying to do? Here is an example of a good question:
Quote:
I am trying to list all of the files that begin with the letter "i" in the directory /home/me/test.
I have used the following command in a terminal window (gnome-terminal) without success.
Code:
ls /home/me/test/i*
The result of issuing that command is the following:
Code:
ls: cannot access /home/me/test/i*: No such file or directory
markush makes a good point. The application, whether it is a video player or a shell in a terminal window, is really what does or does not support regular expressions.

Last edited by stress_junkie; 01-18-2011 at 02:11 PM.
 
1 members found this post helpful.
Old 01-18-2011, 03:44 PM   #6
lynne007
LQ Newbie
 
Registered: Jul 2010
Location: usa
Posts: 10

Original Poster
Rep: Reputation: 0
sorry about not giving more detail.

I was trying to do this:

rename -v 's/\.ccp/\.cpp/' /home/xxx/*.ccp

and this:

rename -v 's/????e0\.cpp/????\.cpp/' /home/xxx/*.cpp


I read this:
http://tips.webdesign10.com/how-to-b...n-the-terminal
with this caveat:
Quote:
UPDATE: I believe the Perl-based rename command is only available on Debian-based Linux distros, but there are instructions on adding it to other distros below.
guess this must be a non Debian-based Linux installation.

I finally ended up with this - which worked.. but was more limited - didn't tell me what was renamed, and it doesn't seem to recognize any regular expression in the find/replace string:

rename .ccp .cpp /home/xxx/*.ccp
rename e0.cpp .cpp /home/xxx/*.cpp
 
Old 01-18-2011, 03:58 PM   #7
markush
Senior Member
 
Registered: Apr 2007
Location: Germany
Distribution: Slackware
Posts: 3,979

Rep: Reputation: 850Reputation: 850Reputation: 850Reputation: 850Reputation: 850Reputation: 850Reputation: 850
Hi,

I'm happy to read that you found a solution.
You may as well read more about the shell (bash), for example here: http://tldp.org/LDP/abs/html/
With a little bash-scripting you can do more advanced renaming on the commandline.

Markus
 
Old 01-18-2011, 09:52 PM   #8
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,256

Rep: Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686
OP - I think you should have looked further down the link you gave us

Towards the bottom is the following line:
Quote:
The code from Ubuntu's rename/prename is here (Gutsy Gibbon).
Simply click on the link and remove the .txt extension, do a chmod +x on the file and throw it in a bin directory
somewhere. Then you have the same rename you are trying to invoke
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Regular expressions bhuwan Programming 5 02-26-2006 12:07 AM
Regular Expressions markjuggles Programming 2 05-05-2005 12:39 PM
help with REGULAR EXPRESSIONS ner Linux - General 23 11-01-2003 12:09 AM
Regular expressions aromes Linux - General 1 10-15-2003 01:29 PM
regular expressions? alaios Linux - General 2 06-11-2003 04:51 PM


All times are GMT -5. The time now is 08:58 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration