Thread: working with files

  1. #1
    UNIX chick
    Join Date
    Mar 2003
    Posts
    92

    working with files

    A while back I created a very simple shell script that basicly (together with a few other things) compiles all the .java files in a directory. Now I want to re-write this shell script in C. This means I'll work with files, and I need to find a way to retrieve the files' name, size etc. Is there a simple way to do this? - Other than forking a lot of UNIX commands..

    Oh, and I haven't found a simple way to get information with fork(), just run UNIX commands and pass/get arguments, which isn't quite the same.

    Help and advice appreciated.

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,666
    > Now I want to re-write this shell script in C.
    I hope this is a "for the fun" exercise, because it's a waste of effort for pratical purposes.
    As a shell script, it takes about 30 seconds to write and is dead easy to maintain and enhance.
    You could spend hours on writing the equivalent C program for no real gain.

    But if you're still interested, then perhaps this will help.

    It sounds like what you really need is make
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    UNIX chick
    Join Date
    Mar 2003
    Posts
    92
    Originally posted by Salem
    You could spend hours on writing the equivalent C program for no real gain.
    That was my conclusion a bit later too. I did hope it would run a bit faster, but figured it wasn't worth all the effort when the shell script could do the job (better) in a few lines. Thanks for the tip and the links.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Program Deployment and DLL/OCX Files?
    By dfghjk in forum C++ Programming
    Replies: 5
    Last Post: 06-16-2008, 02:47 AM
  2. Ressources files
    By mikahell in forum Windows Programming
    Replies: 4
    Last Post: 06-19-2006, 06:50 AM
  3. Working with DLL files...
    By Devil Panther in forum Windows Programming
    Replies: 8
    Last Post: 11-15-2004, 12:42 AM
  4. working with resource files
    By the Wookie in forum Windows Programming
    Replies: 4
    Last Post: 02-01-2003, 10:26 AM
  5. Dos commands hehe
    By Carp in forum A Brief History of Cprogramming.com
    Replies: 2
    Last Post: 01-17-2003, 02:51 PM