Linux - NewbieThis 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!
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
Distribution: On my PC I use RHEL, at office AIX, Solaris, HP-UX, RHEL.
Now here is another scenario:
1) Delete all files which have no extension names- do keep the ones which have them.
2) Delete all files which have extensions names- don't delete the ones which have them.
*Note: Using dot (.) in the criteria may not server the purpose in cases where a file name has multiple dots in it.
[root@localhost ~]# ls
0 44 anaconda-ks.cfg h PingReport
1 5 d hi Ping Report for the Date of:
11 556 data install.log PingStatus.txt
2 56 Desktop install.log.syslog s
22 6 e jj t
3 7 er k work
333 8 f logout-script.txt z
4 9 g names
[root@localhost ~]# rm *.*
rm: remove regular file `anaconda-ks.cfg'? n
rm: remove regular file `install.log'? n
rm: remove regular file `install.log.syslog'? n
rm: remove regular file `logout-script.txt'? n
rm: remove regular file `PingStatus.txt'? n
Example# 2: This includes only those file names which begin with a dot (.)
Whenever you need to change the meaning of a character, the typical thing is to "escape" it with "\". The details depend on the context, but---in general---the use of "\" toggles the meaning of a character from whatever the default is in that situation. You can slog thru something like the Advanced Bash Scripting Guide---or you can simply experiment.
sed 's/./DOT/g' ##replaces all single characters with "DOT"
sed 's/\./DOT/g' ##replaces all literal "."s with "DOT"
(Obviously?) this only applies to characters which may have a special meaning in the context.....
FYI. In your first example, rm [[:lower:]]* will remove files that start with a lower case letter. The "*" in the shell globs "zero or more characters". It isn't used as in grep, sed or awk where it means "zero or more of the preceding character". You can however enable normal regular expressions with the "extglob" option.
Also, in another post, you were looking at hidden files. Be careful if you try to delete hidden files, because ".*" will also match ".." which is the parent directory.
Use ".[^.]*" instead.
There is another gotcha in the order of characters. The $LC_CTYPE locale variable can effect which characters match a regular expression.