|
|
|
|
||||||
| comp.unix.shell Using and programming the Unix shell. |
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
Hello,
I'm running Fedora Core 5 Linux. I was wondering how I would write a shell script, that given a directory name, prints out all the child files, including those in sub-directories. So, for example, if I had a root directory, "base", with two files "a.txt", "b.txt", and one sub-directory "basesub", which contained one file, "basesub/c.txt", I would like my shell script to print out > sh myscript.sh basedir a.txt b.txt basesub/c.txt How can this be done? Thanks, - Dave |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
laredotornado@zipmail.com wrote:
> Hello, > > I'm running Fedora Core 5 Linux. I was wondering how I would write a > shell script, that given a directory name, prints out all the child > files, including those in sub-directories. So, for example, if I had a > root directory, "base", with two files "a.txt", "b.txt", and one > sub-directory "basesub", which contained one file, "basesub/c.txt", I > would like my shell script to print out > > >>sh myscript.sh basedir > > > a.txt > b.txt > basesub/c.txt > > How can this be done? Would this be sufficient for your requirements...? find basedir -type f -print The '-print' might be optional on your system. Janis > > Thanks, - Dave > |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
2006-12-5, 08:43(-08), laredotornado@zipmail.com:
> Hello, > > I'm running Fedora Core 5 Linux. I was wondering how I would write a > shell script, that given a directory name, prints out all the child > files, including those in sub-directories. So, for example, if I had a > root directory, "base", with two files "a.txt", "b.txt", and one > sub-directory "basesub", which contained one file, "basesub/c.txt", I > would like my shell script to print out > >> sh myscript.sh basedir > > a.txt > b.txt > basesub/c.txt > > How can this be done? [...] #! /path/to/your/unix/sh - status=0 for dir do ( cd -P -- "$dir" && exec find . ! -type d -print | sed 's,^\./,,' ) || status=$? done exit "$status" -- Stéphane |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
At 2006-12-05 11:43AM, "laredotornado@zipmail.com" wrote:
> Hello, > > I'm running Fedora Core 5 Linux. I was wondering how I would write a > shell script, that given a directory name, prints out all the child > files, including those in sub-directories. So, for example, if I had a > root directory, "base", with two files "a.txt", "b.txt", and one > sub-directory "basesub", which contained one file, "basesub/c.txt", I > would like my shell script to print out > > > sh myscript.sh basedir > > a.txt > b.txt > basesub/c.txt > > How can this be done? cd $basedir find . -type f -- Glenn Jackman Ulterior Designer |
|
|
|
#5 |
|
Messages: n/a
Hébergeur: |
The carbonbased lifeform laredotornado@zipmail.com inspired
comp.unix.shell with: > Hello, > > I'm running Fedora Core 5 Linux. I was wondering how I would write a > shell script, that given a directory name, prints out all the child > files, including those in sub-directories. So, for example, if I had a > root directory, "base", with two files "a.txt", "b.txt", and one > sub-directory "basesub", which contained one file, "basesub/c.txt", I > would like my shell script to print out > >> sh myscript.sh basedir > > a.txt > b.txt > basesub/c.txt > > How can this be done? #v+ cd $basedir tree --noreport -fiF .| cut -c3-|egrep -v ".*\/$" cd - >/dev/null #v- Theo -- theo at van-werkhoven.nl ICQ:277217131 SuSE Linux linuxcounter.org: 99872 Jabber:muadib at jabber.xs4all.nl AMD XP3000+ 1024MB "ik _heb_ niets tegen Microsoft, ik heb iets tegen de uitwassen *van* Microsoft" |
|
![]() |
| Outils de la discussion | |
|
|