I need a single line command for the next requirement.
Find all the files in the root directory and print only those file names whose name is less than 25.
I assume that we can do this with the find command, as shown below:
find / -type f |xargs basename .... I'm not sure about the furthur team.
find / -type f |xargs basename ....
After briefly looking at some manuals, I need to find awk to make it more convenient and understandable. Check out the solution I came across below.
find / -type f|awk -F'/' '{print $NF}'| awk 'length($0) < 25'
, . , , .
find / -type f|egrep "/[^/]{0,24}$"
, :
find / -type f| egrep -o "/[^/]{0,24}$" | cut -c 2-
My GNU find supports this without knowing if this is part of the standard find.
find / -type f -regextype posix-extended -regex '.*/.{1,24}$'
Alternatively, use find | Grep.
find / -type f | egrep '.*/.{1,24}$'
Using Bash 4+
shopt -s globstar shopt -s nullglob for file in **/* do file=${file##*/} if (( ${#file} < 25 ));then echo "$file"; fi done
Ruby (1.9 +)
ruby -e 'Dir["**/*"].each {|x| puts x if File.basename(x).size < 25}'
Source: https://habr.com/ru/post/1526159/More articles:Writing Unicode to a file using Python - pythonHow to reflect the "Nested sets" model in JPA - javascrollViewTexturedBackgroundColor устарел в iOS 7.0 - iosIs it possible to show the progress on the page when downloading a file? - c #Video recording of portrait activity video - androidHow to navigate a user to log in when not logged in - dartКак интерпретировать R линейную регрессию, когда в качестве базовой линии есть несколько уровней факторов? - rAsyncTask with update? - c #How can I use QueryOver to filter for a specific class? - linqstringByReplacingOccurrencesOfString does not give me the desired result - iosAll Articles