LinuxQuestions.org
Visit Jeremy's Blog.
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 10-29-2009, 11:17 AM   #1
Drigo
Member
 
Registered: Jun 2009
Posts: 111

Rep: Reputation: 17
How to change a common name in files?


Hello,
I have several files with some sort of tag that I willl like to remove how can I do it with a command in linux?

For example:
files:
1. file_a_www.xyz.com
2. file_b_www.xyz.com
3. file_c_www.xyz.com
4. file_d_www.xyz.com
5. file_e_www.xyz.com
6. file_f_www.xyz.com

I want to get rid of www.xyz.com in all files so it looks like:


1. file_a
2. file_b
3. file_c
4. file_d
5. file_e
6. file_f

Also, can I do this for the names of the songs in itunes?
Thanks
 
Old 10-29-2009, 11:32 AM   #2
boondocksaint
LQ Newbie
 
Registered: Oct 2009
Distribution: RHEL4, RHEL5, CentOS, Customized Linux
Posts: 11

Rep: Reputation: 1
you could easily do it with awk...try searching!

here's one: http://www.linuxquestions.org/questi...ight=awk+split
 
Old 10-29-2009, 09:32 PM   #3
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.9, Centos 7.3
Posts: 17,417

Rep: Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397
Code:
echo file_a_www.xyz.com|cut -d'_' -f1,2
file_a
 
Old 10-29-2009, 10:07 PM   #4
ghostdog74
Senior Member
 
Registered: Aug 2006
Posts: 2,697
Blog Entries: 5

Rep: Reputation: 244Reputation: 244Reputation: 244
Code:
for files in *www.xyz.com
do
   echo ${files/_www.xyz.com/}
done
NB: you will have to do the rest of the renaming. its simple. have a go at it.
 
  


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
xfree86-common xserver-common xfonts-base missing in etch/lenny unev_21 Debian 2 09-11-2009 03:12 AM
Multiple Distro's, common files osbert Linux - General 1 07-27-2009 02:19 PM
Perl Script to select common lines in two files. perluser59 Programming 12 05-26-2008 03:19 AM
comparing files..ouput which r not common fs11 Programming 1 06-25-2007 06:09 PM
BOGUS.common.04y -> /home/common/Mailbox jayakrishnan Linux - Networking 0 11-19-2005 05:48 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:28 AM.

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