LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
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 06-07-2007, 07:49 PM   #1
serena86
LQ Newbie
 
Registered: Jun 2007
Posts: 1

Rep: Reputation: 0
help me!! i'm new!!


hi, i'm a new user of linux and having hard time with its many command...so i'm hoping of getting some answers from this forum.

first, i want to change filenames with .txt suffix to .doc suffix. i tried by typing $ mv *.txt*.doc command but it gives me error message. why it doesn't work?
what command should i type to search the root directory??
i want to remove all filenames from my directory that start with a digit and end with ".html". what comand should i type?
 
Old 06-07-2007, 08:04 PM   #2
AceofSpades19
Senior Member
 
Registered: Feb 2007
Location: Chilliwack,BC.Canada
Distribution: Slackware64 -current
Posts: 2,079

Rep: Reputation: 58
it would be more helpfull if you put what word processing program your using
 
Old 06-07-2007, 08:34 PM   #3
alunduil
Member
 
Registered: Feb 2005
Location: San Antonio, TX
Distribution: Gentoo
Posts: 684

Rep: Reputation: 62
Quote:
Originally Posted by serena86
first, i want to change filenames with .txt suffix to .doc suffix. i tried by typing $ mv *.txt*.doc command but it gives me error message. why it doesn't work?
The reason this doesn't work is that bash (I'm assuming you are using bash for a shell) doesn't know how to resolve the two wild cards. While you may look at the two lists, and say well those match up just change the extension bash tries to take the txt list, and just plop it on the doc list. (This last statement is not totally accurate but at least gives the picture.)

For something that does work try a for loop, and the utility basename. All basic Linux commands such as these have a manual and can be accessed by typing
Code:
man <command>
.

Quote:
Originally Posted by serena86
what command should i type to search the root directory??
To search the best utility is locate if you have it and your database is up to date; otherwise, you will have to use find. If you are simply looking for a file by name find is almost simple:

Code:
find / -type f -name '<name>'
Quote:
Originally Posted by serena86
i want to remove all filenames from my directory that start with a digit and end with ".html". what comand should i type?
Now this sounds a bit like a homework question, and I honestly don't remember off hand how to do this without a for loop and grep, but I like to use regular expressions.

Hope this gives you a place to start,

Alunduil
 
Old 06-07-2007, 08:48 PM   #4
gilead
Senior Member
 
Registered: Dec 2005
Location: Brisbane, Australia
Distribution: Slackware64 14.0
Posts: 4,141

Rep: Reputation: 168Reputation: 168
Have a look at the man page for the rename command. You'll need something like rename txt doc *txt. As alunduil posted, the find command can help you identify the files. You can either use its -exec option to remove the files, or pipe its output to xargs. Be very careful about removing files in this way. Use ls instead of rm first so you can see what will be deleted:
Code:
find / -type f -name '<name>' -exec rm -iv {} \;
find / -type f -name '<name>' | xargs rm -iv
 
  


Reply



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



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

All times are GMT -5. The time now is 07:06 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
Open Source Consulting | Domain Registration