In Detail: UNIX File Systems - File names on the shell command line
(Page 5 of 5 )
On the command line, we can select or generalize the file names to which we refer. We can achieve this with the help of the fact that some characters mean other things to the shell than what they mean on their own. These are meta-characters.
For example, the * represents every file and directory inside the current working directory. Of course, we can use it in combination with other characters also. We can represent a single character with the question mark or form a group of letters with the [] syntax. Inside the [] we can enumerate the characters or add a sequence of characters, like from a to z with the a-z syntax.
#print back all the files content
cat *
#print back the content of all txt files
cat *.txt
#print the content of all files containing a single character
cat ?
#print the content of files with a single letter
cat [a-z]
#print the content of files with a single digit
cat [0-9]
#print the content of files with name a.txt,b.xt or c.txt
cat [abc].txt
If inside the file there are meta-characters such as an empty space, we can use them by adding a before them.
# print e content of UNIX File System * file.
cat echo UNIX File System *
With this, we've reached the end of my articles about the UNIX file system. Now you should know enough to understand how files work and you should be able to use the capabilities offered by it to your advantage. Thank you for reading my article and I would also like to ask you to rate it. If you have any questions, do not hesitate to ask them here on the blog, I will answer gladly. Next week I will continue with the UNIX shell so make sure you come back if you are interested. Live With Passion!
| DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware. |