Sponsored Content
Top Forums Shell Programming and Scripting Pick one file from each subdirectory Post 302491585 by Chubler_XL on Thursday 27th of January 2011 08:08:47 PM
Old 01-27-2011
Picks 1st file in alpha order:

Code:
for dir in *
do
   [ -d $dir ] || continue
   for sub in $dir/*
   do
       [ -d $sub ] || continue
       for file in $sub/*
       do
            # process $file header here
            break
       done
   done
done

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to calculate file's size in directory and subdirectory

Hi, I have written one script to calculate total space of all file in one directory, ignoring subdirectory, it works fine. Now, I've been trying to calculate all files which includes files in any subdirectories. I use recursive function to do this, but it can work only if there is only one... (4 Replies)
Discussion started by: KLL
4 Replies

2. UNIX for Dummies Questions & Answers

Create Year directory, date subdirectory and archive the file

Hi, After checking all the UNIX threads, I am able to come up with a solution so far. I am working on a shell script where it moves the files to a certain directory. The conditions to check are 1) Check if the file exists in the current directory. 2) Check if the destination directory... (2 Replies)
Discussion started by: madhunk
2 Replies

3. Shell Programming and Scripting

Sum of file size in directory / subdirectory

Hi , I am trying to write something to find the size of particular type of files in a directory & it's subdirectory and sum the size .. These types of file are found at directory level or its subdirectories level .. #!/bin/ksh FNAME='.pdf' S_PATH=/abc/def/xyz find $S_PATH -exec ls -lad... (4 Replies)
Discussion started by: Vaddadi
4 Replies

4. Shell Programming and Scripting

Search for file and size subdirectory as well

Hi I made this code to search in directory for file and size How can I remodel it to seach in the sub direcotry as well Thanks #!/bin/bash echo -n "Enter: " read var if then echo "Directory exists: ${var}" size=`du -hs "${var}"` echo The size of the current folder is... (4 Replies)
Discussion started by: lio123
4 Replies

5. Shell Programming and Scripting

How can i find a word inside a file from a directory and it's subdirectory ?

Suppose i have a word "mail". I have to search this word in all files inside a directory and it's sub-directories. It will also search in all hidden directory and sub-directories. If it finds this word in any file it will list that file. How can i do this with perl/ruby/awk/sed/bash or... (9 Replies)
Discussion started by: cola
9 Replies

6. Shell Programming and Scripting

Move all files not in a directory into a subdirectory named for each given file

Hi Everyone! Looking for some help with a script that will take all files in any given root folder (which are not already in a folder) and put them into separate folders with the name of each given file. Any ideas? Thank you! (1 Reply)
Discussion started by: DanTheMan
1 Replies

7. Shell Programming and Scripting

how to count how many subdirectory containing more than a certain number of specific file type

hi I want to write a script which count the number of subdirectories in the current root directory that contain more than a specified number of files of a specific type. Is there an easy way to do this? Thanks Robert (2 Replies)
Discussion started by: piynik
2 Replies

8. Shell Programming and Scripting

Searching File in Directory and all Subdirectory and Delete

Hi All, My directory structure is like Directory1 SubDirectory1 SubDirectory2 SubDirectory3 I have main directories and subdirectories underneath. I want to write a shell script where I will be passing file name as a parameter, Now I want to find all the files in Directory1... (19 Replies)
Discussion started by: John William
19 Replies

9. UNIX for Dummies Questions & Answers

List all File Content its subdirectory

Is there anyway to display the file content in a subdirectory that starts or ends with a certain filename, say .txt? or start with NTS $ ls * dos2unix.bat dos2unix.exe test.txt FilePermissions: filepermission.html NTSLA32_SystemDrive.txt NTSLA36_regedit.txt filepermission.sh ... (1 Reply)
Discussion started by: alvinoo
1 Replies

10. Shell Programming and Scripting

Search for specific file type in subdirectory with multiple folders

I have a directory that is in the below order (the --- is not part of the directory tree, only there to help illustrate: DATE --- main level Folder1 --- level under DATE plugin_out --- level under Folder1 variantCaller_out.40 --- level under plugin_out 001,002,003 --- level under... (3 Replies)
Discussion started by: cmccabe
3 Replies
tinydyndns-conf(8)					      System Manager's Manual						tinydyndns-conf(8)

NAME
tinydyndns-conf - sets up a pop-before-dyndns service SYNOPSIS
tinydyndns-conf acct logacct dir myip mydomain DESCRIPTION
tinydyndns-conf creates a service directory dir that runs tinydns(8), and a service directory dir/pop that runs a pop3 service and updates tinydns' database after a successful login. You can run the services under svscan(8) or runsvdir(8) by creating symbolic links in the /service directory: ln -s dir /service/dir ln -s dir/pop /service/dir-pop The service will start within five seconds, and will be restarted upon reboot. You can use svc(8) to control the service. tinydyndns-conf runs tinydns-conf acct logacct dir myip to set up a DNS publication service. tinydyndns-conf modifies dir/root/Makefile to not run tinydns-data(8) upon normal request. tinydyndns-conf arranges for tcpserver(1) to listen on TCP port 110, and to start pop3front-auth(8), cvm-pwfile(8), and after a successful login tinydyndns-update(8), and pop3front-maildir(8) upon connections. tinydyndns-conf creates a setpasswd script and a default passwd database in dir/pop for the use with cvm-pwfile(8). SEE ALSO
tinydyndns-update(8), tinydyndns-data(8), tinydns(8), tcpserver(1), pop3front-auth(8), cvm-pwfile(8), pop3front-maildir(8) http://smarden.org/tinydyndns/ AUTHOR
Gerrit Pape <pape@smarden.org> tinydyndns-conf(8)
All times are GMT -4. The time now is 02:56 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy