Tag Info

New answers tagged

0

Assuming the header is not part of the file: awk -F: ' NR == 1 {max=$2; min=$2; next} length($2) > length(max) {max=$2} length($2) < length(min) {min=$2} END {print "longest=" max; print "shortest=" min} ' songs longest=Rockin' in the Free World shortest=1999


0

! is the find not operator. So to exclude files ending in .ext from the results, include the term ! -name \*.ext. For numeric arguments such as file size, a prefix of + means greater than and a prefix of - means less than. So to find a file larger than 12 kilobytes (really kibibytes) and smaller than 500 Megabytes (really Mebibytes), include the terms -size ...


1

here is a crude script which does what you want find . -name "*.php" -exec wc -L '{}' \; | while read maxlinelength filename do if [ 500 -lt $maxlinelength ] then echo $maxlinelength $filename fi done the output of the find-wc combination is piped to a while read loop which puts each line of maxlinelength and filename in the ...


1

In short, no. The long answer: - Find will run the command specified by exec for every match, so if your find turns up 20 files, it will run 20 seperate instances of rm. - xargs will determine the maximum command length for your shell and add arguments within these limits as you can see with the output of xargs --show-limits mtak@frisbee:~$ xargs ...


0

Find all directories which contain a .git subdirectory: find /home/code -type d -name .git -exec dirname {} \;


1

It's tricky and -maxdepth and recursion trickery won't help here, but here's what I would do: find /home/code -type d -name ".git" | grep -v '\.git/' In english: find me all directories named ".git" and filter out any occurences in the resultlist which contain ".git/" (dot git slash). Above commandline will work on all unix systems, however, if you can ...


4

Sounds like you want the -maxdepth option. find /home/code -maxdepth 2 -type d -name .git


0

To avoid problems with white space, find and IFS magic (filenames can actually contain newlines as well, so IFS=$'\n' is not a silver bullet), one could use globs and arrays. #!/bin/bash search_dir=${1:-.} shopt -s globstar dotglob for svn_dir in "$search_dir"/**/.svn/; do base_dir=${svn_dir%/.svn/} base_dir_contents=("$base_dir"/*) if [ ...


0

resolved the problem that : spaces in Path can call the script with PATH parameter like this: svn-empties YOU_WANT_TO_SEARCH_PATH C_IFS=$IFS IFS=$'\n' for folder in $(find "$1" -depth -type d ! -path *.svn*|sort -r); do counts=$(find "$folder" -type f ! -path *.svn* ! -path $folder | wc -l) if [ $counts -eq 0 ]; then echo $folder fi done ...


1

A file marked executable need not be a executable or loadable file or object. Here is what I use: find ./ -type f -name "*" -not -name "*.o" -exec sh -c ' case "$(head -n 1 "$1")" in ?ELF*) exit 0;; MZ*) exit 0;; #!*/ocamlrun*)exit0;; esac exit 1 ' sh {} \; -print


0

I think Spotlight doesn't index files or directories whose name starts with a period, or at least they are not shown by mdfind. I couldn't find any documentation about it, but for example mdfind kMDItemFSName=.bash_history doesn't find ~/.bash_history either. If you run sudo opensnoop in one shell and mkdir .a;touch .a/{1..1000};mdimport .a in another ...


0

Oh, looking at other people's bashscript I realized I should have backticks around the find command. Like so, for i in `find /torrents/televisionshowS01*/ -name *.rar`; do unrar x "$i" /publicshare/; done and then command functioned the way I wished it to. Though, I'm still not sure WHY, exactly. I'm assuming they work the way parentheses would in math. ...


0

You can also use the -perm and -prune predicates to avoid descending into unreadable directories (see also How do I remove "permission denied" printout statements from the find program? - Unix & Linux Stack Exchange): find . -type d ! -perm -g+r,u+r,o+r -prune -o -name "filetofind" -print


4

To return sorted results, find would have to find everything before it could output anything. That would make things much, much slower. If you need the results sorted, you can easily sort them by piping the output of find to sort.



Top 50 recent answers are included