- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- list file name and size only
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
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
08-12-2004 07:54 AM
08-12-2004 07:54 AM
How do I list only the file name and size within a directory? The "ll|cut fnum,num d " " does not suppress the blank spaces between the fields so I get weird results. I need to feed this information into an array in a Perl program, but Perl is getting confused somewhere around the "print" word with using "awk" in the below.
@array1=system("ll /tmp|awk '{print $5,$9}'");
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-12-2004 07:56 AM
08-12-2004 07:56 AM
Re: list file name and size only
Simply use ls -s
Rgds,
Jeff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-12-2004 07:59 AM
08-12-2004 07:59 AM
Re: list file name and size only
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-12-2004 07:59 AM
08-12-2004 07:59 AM
Re: list file name and size only
ls -1s
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-12-2004 08:01 AM
08-12-2004 08:01 AM
Re: list file name and size only
# ll | awk '{print $5, $NF}'
Dave
I work at HPE
HPE Support Center offers support for your HPE services and products when and how you need it. Get started with HPE Support Center today.
[Any personal opinions expressed are mine, and not official statements on behalf of Hewlett Packard Enterprise]

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-12-2004 08:09 AM
08-12-2004 08:09 AM
Re: list file name and size only
As I mentioned, Perl gets confused when calling awk from the "system" command. This does not work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-12-2004 08:11 AM
08-12-2004 08:11 AM
Re: list file name and size only
# du -k /tmp
See if that gives you what you want.
Dave
I work at HPE
HPE Support Center offers support for your HPE services and products when and how you need it. Get started with HPE Support Center today.
[Any personal opinions expressed are mine, and not official statements on behalf of Hewlett Packard Enterprise]

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-12-2004 08:30 AM
08-12-2004 08:30 AM
Re: list file name and size only
This will not work if the size is in blocks. Or any ideas on how to do this would be most appreciated also. Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-12-2004 08:35 AM
08-12-2004 08:35 AM
Re: list file name and size only
Dave
I work at HPE
HPE Support Center offers support for your HPE services and products when and how you need it. Get started with HPE Support Center today.
[Any personal opinions expressed are mine, and not official statements on behalf of Hewlett Packard Enterprise]

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-12-2004 09:15 AM
08-12-2004 09:15 AM
Re: list file name and size only
k460: /tmp =>ll test1
-rw-r--r-- 1 root sys 29 Aug 12 17:13 test1
du -k * /tmp
1 test1
k460: /tmp =>date>>test1
k460: /tmp =>ll test1
-rw-r--r-- 1 root sys 58 Aug 12 17:11 test1
du -k * /tmp
1 test1
As you can see, the file size has increased but the "du" size did not. This is why it will not work
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-12-2004 09:30 AM
08-12-2004 09:30 AM
Re: list file name and size only
I work at HPE
HPE Support Center offers support for your HPE services and products when and how you need it. Get started with HPE Support Center today.
[Any personal opinions expressed are mine, and not official statements on behalf of Hewlett Packard Enterprise]

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-12-2004 09:35 AM
08-12-2004 09:35 AM
Re: list file name and size only
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-12-2004 09:36 AM
08-12-2004 09:36 AM
Solutionsystem("ll /tmp | awk '{print \$5, \$9}'")
Dave
I work at HPE
HPE Support Center offers support for your HPE services and products when and how you need it. Get started with HPE Support Center today.
[Any personal opinions expressed are mine, and not official statements on behalf of Hewlett Packard Enterprise]

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-12-2004 09:39 AM
08-12-2004 09:39 AM
Re: list file name and size only
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-12-2004 10:17 AM
08-12-2004 10:17 AM
Re: list file name and size only
Jeff Traigle
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-12-2004 11:22 AM
08-12-2004 11:22 AM
Re: list file name and size only
Perl's stat function could be used but "-s" in Perl gives you what you want anyway.
I've over complicated this slightly to populate array1 exactly as you had it (which I guess is not really what you want as I imagine you loop through all the files in it later anyway).
my @array1;
my $file;
my $i = 0;
my @files = glob ("/tmp/*");
foreach $file (@files)
{
@array1[$i++] = -s $file;
@array1[$i++] = $file;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-13-2004 02:23 AM
08-13-2004 02:23 AM