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 ...
- 12-04-2011 #1Just 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
- 12-05-2011 #2Linux 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:
That will create the file /tmp/dir-output.txt, containing the contents of the current working directory.Code:ls -l > /tmp/dir-output.txt
You can look at the contents of the file w/cat:
If you meant something else, provide more detail.Code:cat /tmp/dir-output.txt
- 12-05-2011 #3Just 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
- 12-05-2011 #4Linux 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
- 12-05-2011 #5Just Joined!
- Join Date
- Dec 2011
- Posts
- 5
thanks man i have it working now


Reply With Quote