I have a file called sftp_output with the output of command from a sftp connection that list the content of some folders and look like this:
sftp> ls -l dir1/
-rw------- 1 200 100 1352 Jul 01 14:20 file1
-rw------- 1 200 100 1352 Jul 10 14:20 file2
sftp> ls -l dir2/
-rw------- 1 200 100 1352 Jul 01 14:20 file1
-rw------- 1 200 100 1352 Jul 10 14:20 file2
sftp> bye
What I need to do is filter all the files from dir1 to a single file called "dir1_contents" and files from dir2 to a file called "dir2_contents"
. What is the best approach to do something like that?
The expected result needs to be something like this.
File: dir1_contents
file1
file2
What I need to do is filter all the files from dir1 to a single file called "dir1_contents" and files from dir2 to a file called "dir2_contents"
. What is the best approach to do something like that?
I tried doing something like this
cat sftp_output | grep -v 'sftp' | awk '{print $9}'| sed '/^$/d'