Exercices
Exercice 1
In a directory, create the following files:
annee1 Annee2 annee4 annee45 annee41 annee510 annee_saucisse bananeCreate a
yeardirectory and move all the previous files in theyeardirectory.List all the files that:
- end by 5
- start by
annee4 - start by
annee4and has 7 letters maximum - start by
anneewith no numerical number - contains
ana - start by
aorA
Copy the files whose second-to-last character is either 4 or 1 in the /tmp directory in a single command
Exercice 2 - Grep
- Create a directory called
essai-grepin your home directory. In this directory, create the following files:
tomate poire pomme cerise Fraise fraise courgette POMME3 afraise
Edit the files (output of the ‘ls’ command redirected to ‘grep’) with the following criteria based on their names:
- Criterion 1: The name must be “Fraise” or “fraise”.
- Criterion 2: “se” is at the end of the name.
- Criterion 3: “ai” is present in the name.
- Criterion 4: Name contains a numeric digit.
- Criterion 5: Name contains the string “mm” or “MM”.
Exercice 3 - Find
Search for files in the entire directory tree:
Whose names end with “.c” and redirect errors to the /dev/null file.
Starting with X or x.
Whose names do not contain any digits.
Search for files in the /usr directory whose size exceeds 1MB (2000 blocks of 500KB) and whose permissions are set to 755 (-rwxr-xr-x).
Count the number of files in the entire directory tree that belong to you and have permissions set to 666 (-rw-rw-rw-).
Exercice 4
Create 10 files
.tar.gzin one lineWrite a script that renames the
*.tar.gzto*.tar.gz.old