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
04-28-2003 06:21 AM
04-28-2003 06:21 AM
How do I get the similar result using Perl.
APLF=`ls -l /tmp/file.lck |awk '{print $5}' |cut -d: -f1`
I am trying to get size of a file.
Thanks in advance.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-28-2003 06:32 AM
04-28-2003 06:32 AM
Re: Perl
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-28-2003 06:34 AM
04-28-2003 06:34 AM
Re: Perl
Here is one way to do it in Perl:
#!/usr/bin/perl -w
use File::stat;
$inode = stat("/tmp/file.lck");
$size = $inode->size;
print "Size of /tmp/file.lck is : $size\n";
JP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-28-2003 06:38 AM
04-28-2003 06:38 AM
Re: Perl
open F,"< /tmp/file.lck" or die "Can't open /tmp/file.lck $!";
my $size = (lstat(F))[7];
print "The Size is : $sizei\n";
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-28-2003 06:43 AM
04-28-2003 06:43 AM
Re: Perl
perl -e 'print -s shift,"\n"' /tmp/file.lck
rgds, Robin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-28-2003 06:44 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-29-2003 02:18 AM
04-29-2003 02:18 AM
Re: Perl
Paddy, why use File::Find if you don't use it?
Robin, your post is the best and very correct (as it usually is :), but it can be shorter using the -l command line option, which is very underused:
# perl -le 'print -s shift' /tmp/file.lck
Or even shorter for more files
a5:/u/usr/merijn 103 > perl -le'print-s,$_ for@ARGV' /tmp/xx.txt /tmp/xx.uit
29502/tmp/xx.txt
1230/tmp/xx.uit
a5:/u/usr/merijn 104 >
Enjoy, have FUN! H.Merijn
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-29-2003 02:40 AM
04-29-2003 02:40 AM
Re: Perl
You're right of course, always forgot about that one, although if you're assigning to a variable, you don't need the return anyway :)
Robin