l i n u x - u s e r s - g r o u p - o f - d a v i s
L U G O D
 
Next Meeting:
November 4: Social gathering
Next Installfest:
TBD
Latest News:
Oct. 24: LUGOD election season has begun!
Page last updated:
2003 Jun 23 11:28

The following is an archive of a post made to our 'vox-tech mailing list' by one of its subscribers.

Report this post as spam:

(Enter your email address)
Re: [vox-tech] Shell Scripting Question: Getting a directory name froma 'find' result
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [vox-tech] Shell Scripting Question: Getting a directory name froma 'find' result



--QRtLtq+kfJNLc57H
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Mon, Jun 23, 2003 at 10:54:58AM -0700, Richard Crawford wrote:
> Suppose I have a short script as such:
>=20
> find . -name 'wwwboard.html' -print | while read i
> do
>   print $i
> done
>=20
> how can I pass the name of the directory where $i lurks to another
> variable, such as $dir?

find . -name 'wwwboard.html' -print | sed 's/\/\([^\/]*\)$/ \1/' |=20
  while read dir file; do
    echo "file =3D $file, directory =3D $dir"
  done

Richard,

  The more complex you make things the more you should look into doing
this with perl.

  Also "print" is not a portable shell command... use "echo" instead
when writing shell scripts.

    Hope this helps,
      Mike Simons

--=20
GPG key: http://simons-clan.com/~msimons/gpg/msimons.asc
Fingerprint: 524D A726 77CB 62C9 4D56  8109 E10C 249F B7FA ACBE

--QRtLtq+kfJNLc57H
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE+9z9k4Qwkn7f6rL4RAqgeAJ9elL7Ixbcnebny85itvD9zd7TgGwCeOSHC
el5KKUFCQFyUDB0FfSlRnOg=
=0HrW
-----END PGP SIGNATURE-----

--QRtLtq+kfJNLc57H--
_______________________________________________
vox-tech mailing list
vox-tech@lists.lugod.org
http://lists.lugod.org/mailman/listinfo/vox-tech








LinkedIn
LUGOD Group on LinkedIn
Sign up for LUGOD event announcements
Your email address:
facebook
LUGOD Group on Facebook
'Like' LUGOD on Facebook:

Hosting provided by:
Sunset Systems
Sunset Systems offers preconfigured Linux systems, remote system administration and custom software development.

LUGOD: Linux Users' Group of Davis
PO Box 2082, Davis, CA 95617
Contact Us

LUGOD is a 501(c)7 non-profit organization
based in Davis, California
and serving the Sacramento area.
"Linux" is a trademark of Linus Torvalds.

Sponsored in part by:
EDGE Tech Corp.
For donating some give-aways for our meetings.