Find the answer to your Linux question:
Results 1 to 5 of 5
Hi, im really new to bash scripting. I want to make a dumpfile of my current working directory into a file named dirdump.dmp I have been trying some time now ...
  1. #1
    Just Joined!
    Join Date
    Dec 2011
    Posts
    5

    simple bash script help

    Hi, im really new to bash scripting.
    I want to make a dumpfile of my current working directory into a file named dirdump.dmp

    I have been trying some time now but without succes

    I was wondering if anyone here could help


    Thanks in andvance

  2. #2
    Linux Guru
    Join Date
    May 2011
    Posts
    1,843
    Hey,

    What do you mean by "dump"? Show the contents of the directory maybe? If so, try this:

    Code:
    ls -l > /tmp/dir-output.txt
    That will create the file /tmp/dir-output.txt, containing the contents of the current working directory.

    You can look at the contents of the file w/cat:

    Code:
    cat /tmp/dir-output.txt
    If you meant something else, provide more detail.

  3. #3
    Just Joined!
    Join Date
    Dec 2011
    Posts
    5
    yes that looks right

    but when i run it like that i have edited it now to make the dumpfile of my home folder but it would be better if i can get it to do my current working dir.


    so i guess that would be something like
    ls -l > /pwd/dir-output.txt right?

    yes i am really a novice, i just started learning bash a few days ago

  4. #4
    Linux Guru
    Join Date
    May 2011
    Posts
    1,843
    The ls command will list either the current working directory (the directory you are in), or any arguments (dirs, files, etc.) that you pass to ls on the command line. some examples
    Code:
    # the cd command by itself will cd you into your home dir
    cd
    # ls with no args lists whatever dir you are in
    ls > /tmp/home-listing.txt
    
    # now we are in the /bin dir and listing that dir
    cd /bin
    ls > /tmp/bin-listing.txt
    
    # now it does not matter where we are, we are listing /var
    ls /var > /tmp/var-listing.txt
    
    # now we are passing our $HOME path as an arg to ls
    ls $HOME > /tmp/home-listing.txt

  5. #5
    Just Joined!
    Join Date
    Dec 2011
    Posts
    5
    thanks man i have it working now

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...