0

Hi guys,
I have the following information in a text file, which looks
like this:

-rw-rw-r-- 1 user user 12203 Aug 6 01:02 app1.sql
-rw-rw-r-- 1 user user 12343 Aug 6 01:02 app2.sql
-rw-rw-r-- 1 user user 12238 Aug 6 01:02 app3.sql

I need to Trim the unwanted strings and my output should look like this:

app1.sql
app2.sql
app3.sql

I am not good at string functions...let me know if anyone can help me
out!!

cheers

3
Contributors
3
Replies
4
Views
8 Years
Discussion Span
Last Post by sknake
0
sk@svn:~/test$ ls -al *.sql | awk '{ print $8 }'
file1.sql
file2.sql
file3.sql

If you're reading this from a file you can change it to:

sk@svn:~/test$ ls -al *.sql >> someFile
sk@svn:~/test$ awk '{ print $8 }' someFile
file1.sql
file2.sql
file3.sql
0

you can use Cut filter as demonstarted below:

bash-2.03$ ls -la *.sh > someFile
bash-2.03$ cat someFile
-rwxrwxrwx   1 up       up            60 Aug  6 12:04 hello.sh
-rwxrwxrwx   1 up       up           113 Aug  6 11:35 pyr.sh
-rwxrwxrwx   1 up       up          1287 Aug  6 12:13 run.sh
-rwxrwxrwx   1 up       up           144 Aug  6 11:52 script.sh
bash-2.03$ cat someFile |tr -s ' '|cut -d ' ' -f9
hello.sh
pyr.sh
run.sh
script.sh
bash-2.03$
0

Welcome to daniweb A1! Please use code tags when posting code:

I'm glad to see another shell script solver join the team :) I look forward to seeing your posts!

Edited by happygeek: fixed formatting

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.