Practical Work Activity 1 Part 2.en-1
Practical Work Activity 1 Part 2.en-1
Other commands
We introduce some additional commands for manipulating files and folders.
tree: displays the tree of the current directory (CTRL + C) to stop the command.
date :displays today's date,
cal:displays the calendar,
clear:clears the terminal screen,
man:displays the manual of a command
man ls: displays the ls command manual;
man date: displays the command manual date;
To exit the manual, press the “q” key
find: it allows you to search for a file or a directory.
find/home/tpsys -name image: searches for the image file in the tpsys directory. CTRL+C to stop
searching.
Certain special characters are interpreted by the shell, and are used to describe file names.
'*'means any string.
'?'means any character.
'[ ]'mean a character belonging to a set of values described in the square brackets.
'-'used with square brackets allows you to define an interval, rather than a set of values.
'!'used in brackets in the first position, means any character except those specified in brackets.
Examples:
''f*''All files whose name starts with 'f'.
''f?''All files whose name begins with 'f', followed by any single character.
''f[12xy]''All files whose name begins with 'f', followed by a character to choose from '1, '2', 'x' or 'y'.
''f[a-z]''All files whose name begins with 'f', followed by a character whose ASCII code is between the
code 'a' and the code 'z', so a lowercase letter.
''*.c''All files whose name ends with '.c'
''?.c''All files whose name consists of any character, followed by '.c'
''??''All files whose name consists of two characters.
''*.[A-Za-z]''All files whose name ends with a '.' followed by a single uppercase or lowercase letter.
''*.[ch0-9]''All files whose name ends with a '.' followed by a single character to choose from 'c', 'h', or a
number between '0' and '9'.
''[!f]*''All files whose name does not start with 'f'
''*[!0-9]''All files whose name does not end with a number.
Module Introduction to SE1
Blida University 1 Series of practical work activity part2
Level: 1st year engineer
Remark:
To limit the search to files we use the -type f option.
To limit the search to directories, use the -type d option.
Example:This command searches all directories that are in the documents directory.
Find documents -name '*' -type d
Exercise:Create the following tree in your connection directory:
Desk
folder1 folder2
Supposing we are in d folder, use the find command to search in the d directory:
1) The tp1 file,
2) All files and directories,
3)The tp1, tp2, and tp3 files
4)All files and directories that start with t or c,
5) All files and directories consisting of 3 characters,
6) All folders that do not start with a ‘t’ or an ‘m’,
7)The folder1 directory
8) All directories
9) All files