You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

1.5 KiB

find-files-extension

Instructions

Create a file find-files-extension.sh, which will look, from the current directory and its sub-folders for:

all the files with .txt extension.

That command will only show the name of the files without the extension .txt.

$pwd
<..>/find-files-extension-example
$./find-files-extension.sh | cat -e
qwep$
pq1$
zzzz$
ziko$
wei$
ek$
$

Hints

find command is used to search and locate the list of files and directories based on conditions you specify for files that match the arguments: You can use REGEX in find command.

$find ~/ -iregex '<REGEX>'
<all files and folders in the user home that respect the specified regex>
$

REGEX for txt files: .*\.\(txt\)

cut command is a command-line utility that allows you to cut out sections of a specified file or piped data and print the result:

$cat cut-example.txt 
abc-lol
testtest-abcx
qwerty-azerty-x
$cat cut-example.txt | cut -d "-" -f 1 # cut the lines with "-" as delimiter and print the first part.
abc
testtest
qwerty
$

You may need to use pipes (|) and the logical operator &&.

You have to use Man or Google to know more about commands flags, in order to solve this exercice! Google and Man will be your friends!