Help new to Linux!!!
Hey everyone!!
I am having a problem creating a bash script that will create a text file and then will take the contents of the current working directory and sent it to the text file. Here is what I have so far: #!/bin/bash #Create the Required Text File: cat > /partaTest.txt << EOF #List Files in Text File: ls >> partaTest.txt EOF Any suggestions? Thanks! |
This is all you need...
Code:
#!/bin/bash |
Look's to easy
So the "ls" command will not only print the working directory to the file but also creates it? I have been going crazy thinking there should be more code. I guess its just a simple script.
Thanks for your help!! |
The ls command isn't actually creating the file... but ya, it is that simple.
If you want to append to the file instead of overwrite use the >> instead of the >. |
For a great beginners guide on bash scripting use this site. http://tldp.org/LDP/Bash-Beginners-G...tml/index.html
Also a good book from amazon is http://www.amazon.com/Automating-Lin...0758526&sr=8-3 The ls command is listing the information but the file is created when you use the redirect symbol > to output the results of ls to the partaTest.txt file. |
All times are GMT -5. The time now is 06:31 PM. |