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

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

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$

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!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.