<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: File Size in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/file-size/m-p/3847679#M98022</link>
    <description>SEP,&lt;BR /&gt;&lt;BR /&gt;filename=&lt;BR /&gt;SIZE=$(wc -l $filename)&lt;BR /&gt;echo $SIZE&lt;BR /&gt;&lt;BR /&gt;should be &lt;BR /&gt;filename=&lt;BR /&gt;SIZE=$(wc -c $filename)&lt;BR /&gt;echo $SIZE&lt;BR /&gt;&lt;BR /&gt;isnt? &lt;BR /&gt;&lt;BR /&gt;[-l gives the number of lines&lt;BR /&gt; -c gives the number of bytes]&lt;BR /&gt;</description>
    <pubDate>Tue, 22 Aug 2006 09:51:24 GMT</pubDate>
    <dc:creator>inventsekar_1</dc:creator>
    <dc:date>2006-08-22T09:51:24Z</dc:date>
    <item>
      <title>File Size</title>
      <link>https://community.hpe.com/t5/operating-system-linux/file-size/m-p/3847670#M98013</link>
      <description>Is there an easy way to programmatically read file size either from command line or via script or possible Ansci C funciton?&lt;BR /&gt;&lt;BR /&gt;OS -&amp;gt; 11i</description>
      <pubDate>Mon, 21 Aug 2006 17:43:51 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/file-size/m-p/3847670#M98013</guid>
      <dc:creator>Scott McDade</dc:creator>
      <dc:date>2006-08-21T17:43:51Z</dc:date>
    </item>
    <item>
      <title>Re: File Size</title>
      <link>https://community.hpe.com/t5/operating-system-linux/file-size/m-p/3847671#M98014</link>
      <description>Hi Scott,&lt;BR /&gt;&lt;BR /&gt;The stat(2) system call is probably the most common means of getting this information programmatically.  &lt;BR /&gt;&lt;BR /&gt;Look at the stat(2) man page:&lt;BR /&gt;&lt;BR /&gt;    off_t    st_size;      /* File size (bytes) */&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;The st_size field contains the size of the file in bytes.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;&lt;BR /&gt;Dave</description>
      <pubDate>Mon, 21 Aug 2006 17:51:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/file-size/m-p/3847671#M98014</guid>
      <dc:creator>Dave Olker</dc:creator>
      <dc:date>2006-08-21T17:51:10Z</dc:date>
    </item>
    <item>
      <title>Re: File Size</title>
      <link>https://community.hpe.com/t5/operating-system-linux/file-size/m-p/3847672#M98015</link>
      <description>Hi Scott:&lt;BR /&gt;&lt;BR /&gt;Perl has access to the 'stat(2)' function.  To list the names of files and their size in bytes, you can do:&lt;BR /&gt;&lt;BR /&gt;# perl -le 'die unless @ARGV;print join " = ", $_, (stat($_))[7] for @ARGV' filename&lt;BR /&gt;&lt;BR /&gt;For example:&lt;BR /&gt;&lt;BR /&gt;# perl -le 'die unless @ARGV;print join " = ", $_, (stat($_))[7] for @ARGV' /etc/hosts /etc/services /etc/rc.config.d/netconf&lt;BR /&gt;&lt;BR /&gt;...might return:&lt;BR /&gt;&lt;BR /&gt;/etc/hosts/ = 606&lt;BR /&gt;/etc/services = 9946&lt;BR /&gt;/etc/rc.config.d/netconf = 3987&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 21 Aug 2006 18:16:01 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/file-size/m-p/3847672#M98015</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2006-08-21T18:16:01Z</dc:date>
    </item>
    <item>
      <title>Re: File Size</title>
      <link>https://community.hpe.com/t5/operating-system-linux/file-size/m-p/3847673#M98016</link>
      <description>Hi Scott:&lt;BR /&gt;&lt;BR /&gt;If you want to limit the output only to regular files, amend my original post to:&lt;BR /&gt;&lt;BR /&gt;# perl -le 'die unless @ARGV;for (@ARGV) {print join " = ", $_,(stat(_))[7] if (-f $_)}' /etc/hosts/ /etc/services /etc/rc.config.d&lt;BR /&gt;&lt;BR /&gt;...returns (only):&lt;BR /&gt;&lt;BR /&gt;/etc/hosts/ = 606&lt;BR /&gt;/etc/services = 9946&lt;BR /&gt;&lt;BR /&gt;...since '/etc/rc.config.d' is a *directory*.  My first variation treats files and directories equally and reports their byte-sizes.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 21 Aug 2006 18:34:01 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/file-size/m-p/3847673#M98016</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2006-08-21T18:34:01Z</dc:date>
    </item>
    <item>
      <title>Re: File Size</title>
      <link>https://community.hpe.com/t5/operating-system-linux/file-size/m-p/3847674#M98017</link>
      <description>... and if you already have the file open, the fstat() system call is a little easier because it uses the file descriptor rather than the pathname as the 1st argument.</description>
      <pubDate>Mon, 21 Aug 2006 19:39:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/file-size/m-p/3847674#M98017</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2006-08-21T19:39:36Z</dc:date>
    </item>
    <item>
      <title>Re: File Size</title>
      <link>https://community.hpe.com/t5/operating-system-linux/file-size/m-p/3847675#M98018</link>
      <description>&lt;!--!*#--&gt;If you can live with perl&lt;BR /&gt;there's even an easier way than to stat().&lt;BR /&gt;I wonder why people always forget about &lt;BR /&gt;the simple -s test.&lt;BR /&gt;E.g. this should print a size sorted list of all files in /tmp&lt;BR /&gt;(n.b. usually one would further refine by excluding the single dot references as well as directories etc.)&lt;BR /&gt;&lt;BR /&gt;$ perl -e 'opendir TMP,"/tmp";print map{sprintf"%30s:%10u\n",$_-&amp;gt;[0],$_-&amp;gt;[1]}sort{$a-&amp;gt;[1]&amp;lt;=&amp;gt;$b-&amp;gt;[1]}map[$_,-s "/tmp/$_"],readdir TMP;closedir TMP'&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 22 Aug 2006 04:28:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/file-size/m-p/3847675#M98018</guid>
      <dc:creator>Ralph Grothe</dc:creator>
      <dc:date>2006-08-22T04:28:06Z</dc:date>
    </item>
    <item>
      <title>Re: File Size</title>
      <link>https://community.hpe.com/t5/operating-system-linux/file-size/m-p/3847676#M98019</link>
      <description>Is there an easy way to programmatically read file size either from command line or via script:&lt;BR /&gt;&lt;BR /&gt;"wc -c  filename" will "Report the number of bytes in each input file".&lt;BR /&gt;&lt;BR /&gt;is this fine? &lt;BR /&gt;[ofcourse, u need to cut the result of wc]</description>
      <pubDate>Tue, 22 Aug 2006 09:28:09 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/file-size/m-p/3847676#M98019</guid>
      <dc:creator>inventsekar_1</dc:creator>
      <dc:date>2006-08-22T09:28:09Z</dc:date>
    </item>
    <item>
      <title>Re: File Size</title>
      <link>https://community.hpe.com/t5/operating-system-linux/file-size/m-p/3847677#M98020</link>
      <description>wc -c&lt;FILE&gt;&lt;/FILE&gt;&lt;BR /&gt;HTH,&lt;BR /&gt;Art</description>
      <pubDate>Tue, 22 Aug 2006 09:43:24 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/file-size/m-p/3847677#M98020</guid>
      <dc:creator>Arturo Galbiati</dc:creator>
      <dc:date>2006-08-22T09:43:24Z</dc:date>
    </item>
    <item>
      <title>Re: File Size</title>
      <link>https://community.hpe.com/t5/operating-system-linux/file-size/m-p/3847678#M98021</link>
      <description>Shalom,&lt;BR /&gt;&lt;BR /&gt;Change:&lt;BR /&gt;wc -c filename&lt;BR /&gt;&lt;BR /&gt;filename=&lt;BR /&gt;SIZE=$(wc -l $filename)&lt;BR /&gt;echo $SIZE&lt;BR /&gt;&lt;BR /&gt;SEP</description>
      <pubDate>Tue, 22 Aug 2006 09:46:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/file-size/m-p/3847678#M98021</guid>
      <dc:creator>Steven E. Protter</dc:creator>
      <dc:date>2006-08-22T09:46:46Z</dc:date>
    </item>
    <item>
      <title>Re: File Size</title>
      <link>https://community.hpe.com/t5/operating-system-linux/file-size/m-p/3847679#M98022</link>
      <description>SEP,&lt;BR /&gt;&lt;BR /&gt;filename=&lt;BR /&gt;SIZE=$(wc -l $filename)&lt;BR /&gt;echo $SIZE&lt;BR /&gt;&lt;BR /&gt;should be &lt;BR /&gt;filename=&lt;BR /&gt;SIZE=$(wc -c $filename)&lt;BR /&gt;echo $SIZE&lt;BR /&gt;&lt;BR /&gt;isnt? &lt;BR /&gt;&lt;BR /&gt;[-l gives the number of lines&lt;BR /&gt; -c gives the number of bytes]&lt;BR /&gt;</description>
      <pubDate>Tue, 22 Aug 2006 09:51:24 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/file-size/m-p/3847679#M98022</guid>
      <dc:creator>inventsekar_1</dc:creator>
      <dc:date>2006-08-22T09:51:24Z</dc:date>
    </item>
    <item>
      <title>Re: File Size</title>
      <link>https://community.hpe.com/t5/operating-system-linux/file-size/m-p/3847680#M98023</link>
      <description>Hi Folks:&lt;BR /&gt;&lt;BR /&gt;Leveraging 'stat(2)' to ascertain a file's size is far, far faster then using a tool like 'wc' that has to open and read the actual file.  Compare, for instance, the speed of this:&lt;BR /&gt;&lt;BR /&gt;# perl -le 'printf "%10d %s\n", -s $_,$_ for @ARGV' /stand/vmunix&lt;BR /&gt;&lt;BR /&gt;...with:&lt;BR /&gt;&lt;BR /&gt;# wc /stand/vmunix&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Tue, 22 Aug 2006 09:59:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/file-size/m-p/3847680#M98023</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2006-08-22T09:59:39Z</dc:date>
    </item>
    <item>
      <title>Re: File Size</title>
      <link>https://community.hpe.com/t5/operating-system-linux/file-size/m-p/3847681#M98024</link>
      <description>Yes sekar, &lt;BR /&gt;&lt;BR /&gt;Thanks for correcting my error.&lt;BR /&gt;&lt;BR /&gt;SEP</description>
      <pubDate>Tue, 22 Aug 2006 10:01:16 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/file-size/m-p/3847681#M98024</guid>
      <dc:creator>Steven E. Protter</dc:creator>
      <dc:date>2006-08-22T10:01:16Z</dc:date>
    </item>
  </channel>
</rss>

