![]() ![]() ![]() Emacs ediff and vims vimdiff are both excellent tools for comparing. But do yourself a favor and use a better tool for comparing files/directories. But then again, if you had coreutils installed, you may well have findutils too, with GNU find, and could use -printf '%f\n' to do the same thing. Another way is to just pass the results of the ls command in two files, then compare them, something like: Code: ls -la. ![]() This would call basename as few times as possible. Using standard find, and also making handling the filename suffixes slightly easier: set - txt pdf odsįind /dir1/dir2/dir3/dir4 \( \) -type f -exec basename + ')' to protect them from the shell (where they would otherwise designate a subshell). These parentheses need to be escaped as \(. It turned out I have to put \(.\), as reminded by αғsнιηĪs has already been mentioned, you need to group your -name tests in parentheses. The command I was using is find /dir1/dir2/dir3/dir4/ -type f -name '*.txt' -o -name '*.pdf' -o -name '*.ods' -printf "%f\n" Some of them are open for use by anybody, and. Is it possible to accomplish it using only 1 find command or I have to do it in 2 steps (saving the result in a temporary file, then filter/strip the directory from the temp file)? The result I'm trying to accomplish is a text file with filename per line: file1.txt On using the /etc path in the find instruction with the -L option, it returns many records for bash files. You can also use ls with grep, and use grep s pattern matching capabilities. To list files that have '.c' extensions, use this format: ls. I'm only interested in listing one or more type of file per listing (by using -name to filter my results. To list any files or directories that have names starting with 'ip' use this format: ls ip. Is there any other way to solve this problem?Įxample of my files: /dir1/dir2/dir3/dir4/ What I'd like to do is to list only filenames (not the directory/path), and to complicate more, I have same filename with different extension, so I need to filter the result using -name and -o, the trouble is the suggestions that I saw use either -printf or basename, and those doesn't work well when there's -name *.txt -o name *.pdf. I've checked some answers online, but they do not work when there's a -name parameter in the command (maybe I'm doing something wrong, not sure). ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |