logo
down
shadow

Find Directories with particular tree structure


Find Directories with particular tree structure

By : user3100809
Date : January 12 2021, 09:11 PM
This might help you I want to find directories in the file system which has a particular tree structure. , The following seems to work:
code :
find . -type d -exec sh -c 'cd "$1" && [ -e docker -a -e docker/build.sh -a -e include -a -e config.yaml -a -e src ]' -- {} \; -print


Share : facebook icon twitter icon
Getting tree structure of directories

Getting tree structure of directories


By : Vijay P Singh
Date : March 29 2020, 07:55 AM
it fixes the issue level = root.replace(startpath, '').count(os.sep)
It's calculating level of indentation for printing object (dir/file) name. It's getting rid of startpath as it's common for every listed file and it would look bad to have everything indented by +10 tabs :) os.sep returns path separator like '/' on Linux.
How to find in a directory tree directories containing from 2 to 3 subdirectories?

How to find in a directory tree directories containing from 2 to 3 subdirectories?


By : Deborah Caulet
Date : March 29 2020, 07:55 AM
it should still fix some issue In a given directory tree i want to search directories containing from 2 to 3 subdirectories
code :
find . -type d -printf "%p " -exec find {} \
       -maxdepth 1 -type d -printf "x" \; -printf "\n" | egrep ' x{2,3}$'
List directories and files in a tree structure

List directories and files in a tree structure


By : Aaron
Date : March 29 2020, 07:55 AM
Any of those help If you don't have tree you can use GNU find to identify directories vs files:
code :
$ find . -mindepth 1 -printf '%y %p\n'
d ./dir1
d ./dir1/dir2
f ./dir1/dir2/fileA
d ./dir1/dir3
f ./dir1/fileC
f ./fileB
$ find . -mindepth 1 -printf '%y %p\n' |
    awk '$1=="d"{sub(/.*\//,"&DIR: ")} {gsub(/[^\/]*\//,"  ")} 1'
  DIR: dir1
    DIR: dir2
      fileA
    DIR: dir3
    fileC
  fileB
Loop through tree structure of directories in Azure

Loop through tree structure of directories in Azure


By : Getaji
Date : March 29 2020, 07:55 AM
With these it helps I have the exact same directory structure with an additional folder for each hour in the day. I process each blob in each folder and 'clean' them.
Some pseudo code
Shell - copying directories recursively with RegEx matching preserving tree structure

Shell - copying directories recursively with RegEx matching preserving tree structure


By : Tanya
Date : March 29 2020, 07:55 AM
I wish this help you I need to write a script, that would copy a directory recursively, but only copying subdirectories and files matched by a certain RegEx. For instance for a tree like this: , You can do that using find command and loop through the results:
code :
#!/usr/bin/env bash

cd toDir
while IFS= read -rd '' elem; do
   if [[ -d $elem ]]; then
      mkdir -p ../newDir/"$elem"
   else
      d="${elem%/*}"
      mkdir -p ../newDir/"$d"
      cp "$elem" ../newDir/"$d"
   fi
done < <(find . -name '*[0-9]*' -print0)
Related Posts Related Posts :
  • How to stop $ / being stripped of a string being inserted into a file with sed?
  • Compare lines of a 'specific' column and join the other columns if the lines of the 'specific' colum match
  • How do I recursively append a unique identifier to a series of identical strings in bash?
  • How to sudo su; then run command
  • How to resolve a syntax error of "unexpected token 'then'"?
  • Bash: Conditional Statement Without IF via Grouping Commands and Boolean Operators
  • How to dynamically define a path using a file prefix within a directory?
  • Track pg_dump process id and trigger an error while it fails
  • Multiple commands: do not continue on error
  • How to alias a command if the command contains a certain word at the beginning
  • How to use the exit code of netcat command in a if condition?
  • How can I take multiple arguments in bash using getopts?
  • Name for ${...} constructs (for strings and arrays) in bash?
  • How to determine if an EXIT trap is defined for a BASH subshell?
  • How can you tokenize a bash string into an array when the string includes a * character?
  • Use OPTARG as variable in shell script, no matter the order of arguments
  • Why does my loop occasionally not read the entire line?
  • Is there any shorter syntax for changing several directory levels back up with bash cd?
  • Correctly formatting a PYTHONPATH in my .bash_profile
  • Bash Script : Check if number starts with
  • im getting a syntax error when i run my shell script, the error is in my for each loop and says unespected token `;;'
  • Write a shell script that will return the list of files skipped by your repository git
  • Create a shell script that returns the last 5 hash of my commits of my git deposit
  • How to copy Associative Array without for loop
  • Extract specific string from line with standard grep,egrep or awk
  • Copy files that have at least the mention of one certain word
  • How it exactly works?
  • How to insert a specific character at a specific line of a file using sed or awk?
  • How to create bash script that combines specified list of items at random?
  • How to get the return code from the bash command
  • Running a bash find with file cp parameter error python script
  • How to pass a file as an argument to a bash script function?
  • How can I pass a complex file glob to a subshell?
  • Standard-in parse errors with bc command
  • Using AWK to merge unique rows based on column one
  • Bash Login Script Stalls
  • BASH replace a single letter only when it's alone not in a word
  • Compare 4 files line by line to see if they match or don't match
  • Add character to file name if duplicate when moving with bash
  • Use grep only on specific columns in many files?
  • xor conditional in bash
  • Fails to create azure container right after storage account was created
  • bash: arithmetic expressions inside of variables
  • jq command throws error "cannot iterate over string" when
  • In Bash, should I use declare instead of local and export?
  • Grouping command substitution variables into a subshell to run in background
  • How to display number of items in a folder - Bash
  • How to create a new procedure from bash script
  • Sed command to uppercase text between two specific strings
  • Escape double quotes in a Jenkins pipeline file's shell command
  • pgrep -f cuts commands after 4095 characters
  • I want my script to echo "$1" into a file literally
  • Shell script: unexpected token ´if"
  • scp error when defining a "PATH" variable in a bash script
  • Nested loop for reading two files with bash
  • Find folders with a specific name and run bash commands on each location
  • Replication and expansion of program flags in BASH script
  • Error on certain line: Syntax error: "(" unexpected
  • Terminal not returning to normal after Bash Script
  • what code function will help to ask for input when i try to execute a code with no previous value in shell script
  • shadow
    Privacy Policy - Terms - Contact Us © festivalmusicasacra.org