LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   help me!! i'm new!! (https://www.linuxquestions.org/questions/linux-newbie-8/help-me-im-new-560070/)

serena86 06-07-2007 07:49 PM

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??:scratch:
i want to remove all filenames from my directory that start with a digit and end with ".html". what comand should i type?

AceofSpades19 06-07-2007 08:04 PM

it would be more helpfull if you put what word processing program your using

alunduil 06-07-2007 08:34 PM

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

gilead 06-07-2007 08:48 PM

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



All times are GMT -5. The time now is 07:29 PM.