![]() In other words, only files that contain only lower-case letters in their name. You then ask grep to list the filenames ( -l) that contain the string "file" among the files in /usr/bin that do not ( !) match the pattern: "anything ( *) followed by any single ( ) non ( ^) -lower-case letter ( a-z), followed by anything ( *). ![]() If your grep supports the -r or -R option for recursive search, use it. What's going wrong here is that you have a file whose name must be quoted on input to xargs (probably containing a ' ). This turns on bash's extended globbing functionality. 6 Answers Sorted by: 24 xargs expects input in a format that no other command produces, so it's hard to use effectively. While it's not expectedd, I would suggest the following safer option, assuming a bash shell: shopt -s extglob old extension from your home directory (including subdirectories). If you only want the ones with lower-case change -iname to -name. This command will remove any file with a. zip files in current directory and all sub-directories try this: find. which then complained about the missing files. To delete a file, you need to add the -exec rm command as shown below. In Linux (command line): I need to find all Perl-files (filename ends with. Grep rightfully passed both of those "filenames" down the pipe to xargs, which then thought it had two filenames to grep against, and so it ran: grep file a b In the above example, ls wrote the following contents to the pipe for grep: a (Files with spaces in them Some File Name will be excluded by the grep.) For a contrived example to show the point: cd ~/tmp/usr/bin ![]() For example, say we have the following files (called grep. -r is for recursive -e is optional but its argument specifies the regex to search for. If there is no match, no output will be printed to the terminal. The result of this is the occurences of the pattern (by the line it is found) in the file (s). This runs into immediate trouble as soon as any filenames (unlikely as these are to be in /usr/bin) contain a newline. You can also use the wildcard () to select all files in a directory. Where you ask ls for the filenames, then have grep filter ones that start ( ^) and end ( $) with only lower-case letters - zero or more of them ( *) you then ask xargs to grep each incoming filename for the string "file". another syntax to grep a string in all files on a Linux system recursively. Your assignment may expect you to grep the output of ls, perhaps something like this: cd /usr/bin ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |