- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: list file problem
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-14-2007 01:32 AM
12-14-2007 01:32 AM
list file problem
./test1.txt
./test2.txt
./test3.txt
my desired output is
test1.txt
test2.txt
test3.txt
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-14-2007 01:43 AM
12-14-2007 01:43 AM
Re: list file problem
Try,
# find . -type f -exec ls {} \; | awk -F/ '{ print $2 }'
# find . -type f | xargs ls | awk -F/ '{ print $2}'
Robert-Jan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-14-2007 01:50 AM
12-14-2007 01:50 AM
Re: list file problem
#find . -type f -exec ls {} \; | cut -c 3-
Best Luck.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-14-2007 01:51 AM
12-14-2007 01:51 AM
Re: list file problem
It is probably safer to remove the "./" then use awk -F/:
$ find . -type f -exec ll -t + | sed 's:\./::'
Especially if find goes into subdirectories.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-14-2007 02:26 AM
12-14-2007 02:26 AM
Re: list file problem
$ find . -type f -exec ls -lt {} \;
-rw-r--r-- 1 user group 0 Dec 14 11:46 ./testdir/test4.txt
-rw-r--r-- 1 user group 0 Dec 14 11:46 ./test1.txt
-rw-r--r-- 1 user group 0 Dec 14 11:46 ./test2.txt
-rw-r--r-- 1 user group 0 Dec 14 11:46 ./test3.txt
$ find . -type f -exec ls -lt {} \; | sed -e 's! ./! !'
-rw-r--r-- 1 user group 0 Dec 14 11:46 testdir/test4.txt
-rw-r--r-- 1 user group 0 Dec 14 11:46 test1.txt
-rw-r--r-- 1 user group 0 Dec 14 11:46 test2.txt
-rw-r--r-- 1 user group 0 Dec 14 11:46 test3.txt
Note that "-exec
The "-exec
$ find . -type f -exec ls -lt \+ | sed -e 's! ./! !'
-rw-r--r-- 1 mkurkela mkurkela 0 Dec 14 11:46 testdir/test4.txt
-rw-r--r-- 1 mkurkela mkurkela 0 Dec 14 11:46 test3.txt
-rw-r--r-- 1 mkurkela mkurkela 0 Dec 14 11:46 test2.txt
-rw-r--r-- 1 mkurkela mkurkela 0 Dec 14 11:46 test1.txt
MK
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-14-2007 02:50 AM
12-14-2007 02:50 AM
Re: list file problem
my desired output should be as below , can advise how to do it ? thx
-rw-r--r-- 1 user1 edp 1296 Jun 20 07:11 test1.txt
-rw-r--r-- 1 user1 edp 1296 Jun 20 07:11 test2.txt
-rw-r--r-- 1 user1 edp 1296 Jun 20 07:11 test3.txt
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-14-2007 02:57 AM
12-14-2007 02:57 AM
Re: list file problem
My sed will do that. But as MK says, it may not be sorted the way you want.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-14-2007 02:59 AM
12-14-2007 02:59 AM
Re: list file problem
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-14-2007 03:12 AM
12-14-2007 03:12 AM
Re: list file problem
Actually MK forgot to quote the ".". But he did guard for embedded ".". by using a space, so:
... | sed 's: \./: :'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-14-2007 07:48 AM
12-14-2007 07:48 AM
Re: list file problem
# find `pwd` -type f -exec ll -lt {} \;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-14-2007 11:04 PM
12-14-2007 11:04 PM
Re: list file problem
Using $PWD in find will give absolute paths for everything.
$ find $PWD -type f -exec ll +
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2007 02:47 AM
12-18-2007 02:47 AM
Re: list file problem
why not only:
ls -lt|grep -v ^d
You will have a list of file in cronological order in current directory but not directories
HTH,
Art
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-21-2007 02:58 AM
12-21-2007 02:58 AM
Re: list file problem
I tried all command above , but the output file name still have ./ as below
Now the output
==============
-rw-r--r-- 1 user1 edp 1296 Jun 20 07:11 ./test1.txt
-rw-r--r-- 1 user1 edp 1296 Jun 20 07:11 ./test2.txt
-rw-r--r-- 1 user1 edp 1296 Jun 20 07:11 ./test3.txt
My desired output
=================
-rw-r--r-- 1 user1 edp 1296 Jun 20 07:11 test1.txt
-rw-r--r-- 1 user1 edp 1296 Jun 20 07:11 test2.txt
-rw-r--r-- 1 user1 edp 1296 Jun 20 07:11 test3.txt
can advise what can i do ? thx
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-21-2007 04:07 AM
12-21-2007 04:07 AM
Re: list file problem
I thought I mentioned why on reply with 11:12:26 GMT. Try this:
$ find . -type f -exec ll -t + | sed 's: \./: :'