1830895 Members
2671 Online
110017 Solutions
New Discussion

list file problem

 
ust3
Regular Advisor

list file problem

When I use ls -lt ./* to list file , the output is as below , all have ./ sign in every fle , can advise how to erase the ./ of the output ? Thx

./test1.txt
./test2.txt
./test3.txt

my desired output is
test1.txt
test2.txt
test3.txt

ps. I must use this command ls -lt ./*
7 REPLIES 7
Shrikant Lavhate
Esteemed Contributor

Re: list file problem

try

#ls -lt ./* -exec ls {} \; | cut -c 3-

Will it remain a personal, if I broadcast it here!
Shrikant Lavhate
Esteemed Contributor

Re: list file problem

Sorry it was meant for other forum post. :D

You can use strem editor sed in your case with ls command.

Will it remain a personal, if I broadcast it here!
Dennis Handly
Acclaimed Contributor

Re: list file problem

If you look at your other thread, you should find some examples:
http://forums11.itrc.hp.com/service/forums/questionanswer.do?threadId=1185161
$ ls -lt ./* | sed 's: \./: :'

Note if there are subdirectories in ".", you'll list them too, unless you add -d.
Steven Schweda
Honored Contributor

Re: list file problem

> ps. I must use this command ls -lt ./*

Why? Would "ls -lt *" (or better, "ls -lt")
be too easy?
Geoff Wild
Honored Contributor

Re: list file problem

ls -lt ./* |awk -F/ '{print $2}'

Rgds...Geoff
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
Dennis Handly
Acclaimed Contributor

Re: list file problem

>my desired output is: test1.txt

I assume you want the rest of the line too?
-rw-rw-r-- 1 uuu ggg 73728 Jan 3 13:55 test1.txt
Arturo Galbiati
Esteemed Contributor

Re: list file problem

Hi,
use ls -lt only or ls -lt ./*|awk '{sub("./","");print}'

HTH,
Art