touch, pwd & ls Commands in Unix/Linux


ls : List Files 

ls -l   : shows file or directory, size, modified date and time, file or folder name and owner of file and its permission.

ls -a   : view hidden files

touch .myfile.txt

ls -a

ls -l -a : detailed listing files along with hiddwn files

ls -F : will add the ‘/’ Character at the end each directory.

ls -r : display files and directories in reverse order.

ls -R : displays directories along with sub subdirectories

ls -lS : displays file size in order, will display big in size first.

ls -l Documents : list files under directory Documents

wild card characters


? Single character

* Multiple characters

[ ] Range of values

ls ?.*

Output: a.doc  b.doc  c.doc  x.txt  y.txt

ls ?.doc

Output: a.doc  b.doc  c.doc

ls ?.txt

Output: x.txt  y.txt

ls a* Displays files which are starting with 'a'

Output: abc.doc  a.doc

Range(Displays files starting with a to z)

ls [a-z]*.*

ls [a-c]*.*

ls [a-z]*.txt

rm ?.* Removes the files with single character

rm *.txt Removes the files with extension txt

rm *.doc Removes the files with extension txt