Help with Linux using ubuntu 5. What command, issued from your home directory, w
ID: 3841851 • Letter: H
Question
Help with Linux
using ubuntu
5. What command, issued from your home directory, will output the number of directories and files in /usr/share/man which contain at least one digit in their extensions?
ls -ld *.[0-9] /usr/share/man
didnt work
7. What ls command used with a globbing expression will list those files in /tmp/notes which contain three fours in the basename portion (pre-extension part) of the filename? (Must use globbing expression--no grep!)
tried ls *444* /tmp/notes
ls *[444]. /tmp/notes
niether work say directory does not exist then lists the folders entire contents
Explanation / Answer
5.)What command, issued from your home directory, will output the number of directories and files in /usr/share/man which contain at least one digit in their extensions?
Method 1:
We will use the tree feature which is very easy and at the same time very fast in listing all the files and folders under the given folder.
Syntax:
tree directory_path | tail -1
Example:
tree/users/Desktop/User | tail -1
Method 2:
We can also do the same by using find command which will help in listing all the files and folders in the current folder and the wx -l which will count results of find
Syntax
find . -type f -printf . | wc -l
Example
If we are required to find files and folders in Desktop that we will type
find . -type f -printf . | wc -l
7. What ls command used with a globbing expression will list those files in /tmp/notes which contain three fours in the basename portion (pre-extension part) of the filename? (Must use globbing expression--no grep!)
Method 1:
We can use ls followed by *444* as that will list out all the filenames containing 444 it's name
Syntax
ls *444* # will list all the files which contains --444--
More Info:
ls 444*# list all files starting with 444---
ls *444 # list all files ending with --444
METHOD 2:
We can use the tree command also
Syntax
tree -P *444* # will help in listing all files containing --444--
More Info:
tree -P '444*' # will help in listing all files starting with 444---
Hope it helps....
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.