Hi all,
I've hit a blank and am not sure how to get around this. (Let alone explain it properly ;-) … I’ll try my best)
I tried searching the forums but found nothing that seems to match what I’m wanting to do.
It’s like this. I have a bunch of directories which I want to ls -lt on and awk the 9th column into a file. This will leave me with a column list which I need to use as a source for another script.
Eg:
ls -lt | awk ‘{print $9}’ > dirlist.txt
dirlist.txt will contain only the directory names then, like so:
directory1
directory2
directory3
directory4
directory5
directory6
directory7
directory8
directory9
directory10
Now I have another file which lists a number of these directory names which I’d like to have excluded or preferably marked with a hash.
Eg:
So the excludefile.txt will contain
directory6
directory8
directory10
So ideally what I’d like to have is the dirlist.txt (or another if a new one needs to be created) looking something like this:
directory1
directory2
directory3
directory4
directory5
# directory6
directory7
# directory8
directory9
# directory10
I’ve tried doing the above with a for loop and sed but I think I’m heading down the wrong route and complicating things.
Anyone have any ideas I should consider or a simple way to do the above?
Thanks … T
I've hit a blank and am not sure how to get around this. (Let alone explain it properly ;-) … I’ll try my best)
I tried searching the forums but found nothing that seems to match what I’m wanting to do.
It’s like this. I have a bunch of directories which I want to ls -lt on and awk the 9th column into a file. This will leave me with a column list which I need to use as a source for another script.
Eg:
ls -lt | awk ‘{print $9}’ > dirlist.txt
dirlist.txt will contain only the directory names then, like so:
directory1
directory2
directory3
directory4
directory5
directory6
directory7
directory8
directory9
directory10
Now I have another file which lists a number of these directory names which I’d like to have excluded or preferably marked with a hash.
Eg:
So the excludefile.txt will contain
directory6
directory8
directory10
So ideally what I’d like to have is the dirlist.txt (or another if a new one needs to be created) looking something like this:
directory1
directory2
directory3
directory4
directory5
# directory6
directory7
# directory8
directory9
# directory10
I’ve tried doing the above with a for loop and sed but I think I’m heading down the wrong route and complicating things.
Anyone have any ideas I should consider or a simple way to do the above?
Thanks … T