script to read paths
hallo for a newbie to shell programming!!i have to read all files from a folder,then open a new file which have all the paths from each file which i had read!!i begin like this:touch newfile,then make a loop to read the folder,using find and cp to copy it!then i use cat newfile!!!any help pls???
|
Code:
ls -l /my/folder > /myfile; cat /myfile |
Or (more complete and more robust)
Code:
echo /my/folder/.* /my/folder/* > /tmp/myfile; cat /tmp/myfile |
Quote:
It would help if you posted what you have tried, any output and an explanation of how it differs from what you want. |
sorry i can't understand very well!!is my first script and is a mess!i can't read the file(name task) and print the paths which files have in a new file(name paths.txt)....the paths.txt must create it!!!!!
|
Are you trying to create a file that contains the names of all of the files in a directory, or do you have a directory full of files, each of which contains a list of files, and you're trying to create a single file that contains all of the filenames listed in each of the files in the directory?
It's hard to understand what you're trying to do. Maybe if you give an example it would be easier. |
the second!!thank you!
|
This should do what you want, of course you might want to clean it up a bit, but this should give you the general gist.
Code:
#!/bin/bash |
I tried it and it worked but the problem is that it showed me only the files in my folder, but i want it to show the files in the subfolder which are in my folder. Have any idea how to do that?
|
Code:
#!/bin/bash Alternatively: Code:
> /tmp/myfile # Empty it |
Quote:
OP - if you would like to include subdirectories then you should use "find" as catkin suggested. |
thanks for the help!!!
|
All times are GMT -5. The time now is 02:32 PM. |