troubleshooting Question

How to remove series of files using awk print command itself?

Avatar of BharathKumarRaju DasaraRaju
BharathKumarRaju DasaraRajuFlag for India asked on
Unix OSLinuxLinux Distributions
4 Comments1 Solution694 ViewsLast Modified:
I can do the deletion with the below command...
bharathkumar@vm-0:~$ ls -lrt [0-9]* | awk '{print $NF}' | xargs kill -9

But i need to try with help pf print command itself below.......why it is not deleting is there any way to do the deletion... please advise?

bharathkumar@vm-0:~$ ls -lrt [0-9]* | awk '{print $NF}'
1
2
3
4
5
6
7
9
8
10
bharathkumar@vm-0:~$ ls -lrt [0-9]* | awk '{print "rm -f " $NF}'
rm -f 1
rm -f 2
rm -f 3
rm -f 4
rm -f 5
rm -f 6
rm -f 7
rm -f 9
rm -f 8
rm -f 10

bharathkumar@vm-0:~$ ls -lrt [0-9]*                                                                                                                                                 
-rw-r--r-- 1 bharathkumar bharathkumar 0 Sep 13 05:52 1
-rw-r--r-- 1 bharathkumar bharathkumar 0 Sep 13 05:52 2
-rw-r--r-- 1 bharathkumar bharathkumar 0 Sep 13 05:52 3
-rw-r--r-- 1 bharathkumar bharathkumar 0 Sep 13 05:52 4
-rw-r--r-- 1 bharathkumar bharathkumar 0 Sep 13 05:52 5
-rw-r--r-- 1 bharathkumar bharathkumar 0 Sep 13 05:52 6
-rw-r--r-- 1 bharathkumar bharathkumar 0 Sep 13 05:52 7
-rw-r--r-- 1 bharathkumar bharathkumar 0 Sep 13 05:52 9
-rw-r--r-- 1 bharathkumar bharathkumar 0 Sep 13 05:52 8
-rw-r--r-- 1 bharathkumar bharathkumar 0 Sep 13 05:52 10
bharathkumar@vm-0:~$  
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 4 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros