Hi I am trying to find all js & css files in one find command. I tried all of the below but in vain:
find WebContent -name "*.[jc]ss?"
find WebContent -name "*.[jc]ss{0,1}"
find WebContent -name "*.[jc][s]{1,2}$"
find WebContent -name "*.[jc]s{1,2}"
find WebContent -name "*.[jc]s[s]?"
Now what??
The find command in UNIX is a command line utility for walking a file hierarchy. It can be used to find files and directories and perform subsequent operations on them. It supports searching by file, folder, name, creation date, modification date, owner and permissions.
The number can be a positive or negative value. A negative value equates to less then so -1 will find files modified within the last day. Similarly +1 will find files modified more than one day ago.
Finding text strings within files using grep-r – Recursive search. -R – Read all files under each directory, recursively. Follow all symbolic links, unlike -r grep option. -n – Display line number of each matched line.
One of the easiest and fastest methods of locating text contained within a file on a computer running Linux is to use the grep command. Below is a basic example of a command used to locate any htm file containing the word "help". If any matches are found, text similar to the following example is shown.
-name
accepts arguments that are globs, not regular expressions. You could use -regex
if you wanted to use regular expressions, but the -o
option (meaning "or") is probably the simplest solution:
find WebContent -name "*.js" -o -name "*.css"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With