Linux / UNIX Tech Support Forum
This is a discussion on Shell script that create a blank file in all sub-directories. within the Shell scripting forums, part of the Development/Scripting category; Hi All, Can some body write me a script (shell script) which can create a blank test file in all ...
|
Register free or login to your existing account and remove all advertisements. |
|
|||||||
| Shell scripting You can discuss the shell scripting, request shell scripts and scripting techniques |
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
Hi All,
Can some body write me a script (shell script) which can create a blank test file in all sub-directories upto 5-6 levels? I am using RHEL. thanks |
| Sponsored Links | ||
|
|
|
||||
|
No need to write a shell script, simply use the following:
Code:
find . -maxdepth 5 -empty -type d | xargs -I currentDir -t touch currentDir/empty.txt
__________________
Vivek Gite Linux Evangelist |
|
|||
|
Quote:
============ Thanks for your response. First of I dont know the depth level, it can be 1 and can be 6 or 9/10. I can get the list of the dirs with the following command find / -type d -exec ls -d {} \; $ find test-drs/ -type d -exec ls -d {} \; test-drs/ test-drs/test test-drs/test/jami test-drs/test/vijay test-drs/dev test-drs/dev/ben test-drs/dev/alex/one test-drs/dev/simon/ian/scott test-drs/sys test-drs/sys/din test-drs/sys/din/khan test-drs/sys/anu All i want to create the file in all these subdirectories but the depth level should be dinamic. I run that commmand you mentioned [admin@example test-drs]$ find . -maxdepth 5 -empty -type d | xargs -I currentDir -t touch currentDir/empty.txt xargs: invalid option -- I Usage: xargs [-0prtx] [-E eof-str] [-e[eof-str]] [-I replace-str] [-i[replace-str]] [-L max-lines] [-l[max-lines]] [-n max-args] [-s max-chars] [-P max-procs] [--null] [--eof[=eof-str]] [--replace[=replace-str]] [--max-lines[=max-lines]] [--interactive] [--max-chars=max-chars] [--verbose] [--exit] [--max-procs=max-procs] [--max-args=max-args] [--no-run-if-empty] [--version] [--help] [command [initial-arguments]] Report bugs to <bug-findutils@gnu.org>. [admin@example test-drs]$ find . -maxdepth 5 -empty -type d | xargs -i currentDir -t touch currentDir/empty.txt xargs: currentDir: No such file or directory any help? |
![]() |
| Tags |
| find , find empty directory , linux , pipes , shell pipes , shell scripting , unix , xargs |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) |
|
| Thread Tools | |
| Display Modes | |
|
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| [Solved] Shell script for ftp the file | vishal_titre | Shell scripting | 4 | 08-21-2009 03:50 PM |
| Shell Script To Create Network Configuration | Murray | Shell scripting | 4 | 02-17-2009 05:40 PM |
| Shell Script To Outputs File Permissions of Most Recently Modified File | glen_4455 | Shell scripting | 1 | 08-25-2008 02:39 PM |
| shell script to search specific file from txt file inside zip file and extract it | aasif.shaikh | Shell scripting | 2 | 05-31-2008 06:44 PM |
| error shell script no such file or directory /bin/sh | Linux software | 1 | 01-08-2006 08:34 PM | |