<?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 C code required. in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/c-code-required/m-p/3113250#M717586</link>
    <description>&lt;BR /&gt;Any of you C guru's out there got a nifty piece of code that will return the name of the oldest file or directory in the current directory?&lt;BR /&gt;&lt;BR /&gt;Im not looking for a system call!</description>
    <pubDate>Fri, 07 Nov 2003 07:44:46 GMT</pubDate>
    <dc:creator>Nigel Green</dc:creator>
    <dc:date>2003-11-07T07:44:46Z</dc:date>
    <item>
      <title>C code required.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/c-code-required/m-p/3113250#M717586</link>
      <description>&lt;BR /&gt;Any of you C guru's out there got a nifty piece of code that will return the name of the oldest file or directory in the current directory?&lt;BR /&gt;&lt;BR /&gt;Im not looking for a system call!</description>
      <pubDate>Fri, 07 Nov 2003 07:44:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/c-code-required/m-p/3113250#M717586</guid>
      <dc:creator>Nigel Green</dc:creator>
      <dc:date>2003-11-07T07:44:46Z</dc:date>
    </item>
    <item>
      <title>Re: C code required.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/c-code-required/m-p/3113251#M717587</link>
      <description>How about ls -u | head?&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Pete</description>
      <pubDate>Fri, 07 Nov 2003 07:49:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/c-code-required/m-p/3113251#M717587</guid>
      <dc:creator>Pete Randall</dc:creator>
      <dc:date>2003-11-07T07:49:08Z</dc:date>
    </item>
    <item>
      <title>Re: C code required.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/c-code-required/m-p/3113252#M717588</link>
      <description>Or ls -lc |head?&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Pete&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 07 Nov 2003 07:50:16 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/c-code-required/m-p/3113252#M717588</guid>
      <dc:creator>Pete Randall</dc:creator>
      <dc:date>2003-11-07T07:50:16Z</dc:date>
    </item>
    <item>
      <title>Re: C code required.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/c-code-required/m-p/3113253#M717589</link>
      <description>what about next:&lt;BR /&gt;ls -alrt | grep -v total | head -1 | awk '{ print $9 }'&lt;BR /&gt;&lt;BR /&gt;This wil also return ".filenames"&lt;BR /&gt;&lt;BR /&gt;(why use C)</description>
      <pubDate>Fri, 07 Nov 2003 07:58:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/c-code-required/m-p/3113253#M717589</guid>
      <dc:creator>Hoefnix</dc:creator>
      <dc:date>2003-11-07T07:58:59Z</dc:date>
    </item>
    <item>
      <title>Re: C code required.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/c-code-required/m-p/3113254#M717590</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;Pete is right, just use ls:&lt;BR /&gt;&lt;BR /&gt;ls -lt is an other option.&lt;BR /&gt;&lt;BR /&gt;Gideon&lt;BR /&gt;</description>
      <pubDate>Fri, 07 Nov 2003 08:03:01 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/c-code-required/m-p/3113254#M717590</guid>
      <dc:creator>G. Vrijhoeven</dc:creator>
      <dc:date>2003-11-07T08:03:01Z</dc:date>
    </item>
    <item>
      <title>Re: C code required.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/c-code-required/m-p/3113255#M717591</link>
      <description>In C it will have to be a combo of stat(2) and the directory(3C) calls, I think. I haven't tried the code below, but it should work, according to the manpages:&lt;BR /&gt;&lt;BR /&gt;#include &lt;SYS&gt;&lt;BR /&gt;#include &lt;DIRENT.H&gt;&lt;BR /&gt;#include &lt;SYS&gt;&lt;BR /&gt;&lt;BR /&gt;void main() {&lt;BR /&gt;  int old_time=-1;&lt;BR /&gt;  char old_name[MAXNAMLEN+1] = "";&lt;BR /&gt;  DIR *dirp;&lt;BR /&gt;  struct dirent *dp;&lt;BR /&gt;  struct stat stb;&lt;BR /&gt;&lt;BR /&gt;  dirp = opendir(".");&lt;BR /&gt;  while ((dp = readdir(dirp)) != NULL) {&lt;BR /&gt;    stat(dp-&amp;gt;d_name,&amp;amp;stb);&lt;BR /&gt;   &lt;BR /&gt;    if ((old_time &amp;gt; stb.st_ctime) || (old_time==-1)){&lt;BR /&gt;      old_time = stb.st_ctime;&lt;BR /&gt;      strcpy(old_name,dp-&amp;gt;d_name);&lt;BR /&gt;    }&lt;BR /&gt;  }&lt;BR /&gt;  printf("Oldest file: %s\n",old_name);&lt;BR /&gt;}&lt;/SYS&gt;&lt;/DIRENT.H&gt;&lt;/SYS&gt;</description>
      <pubDate>Fri, 07 Nov 2003 08:13:23 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/c-code-required/m-p/3113255#M717591</guid>
      <dc:creator>Elmar P. Kolkman</dc:creator>
      <dc:date>2003-11-07T08:13:23Z</dc:date>
    </item>
    <item>
      <title>Re: C code required.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/c-code-required/m-p/3113256#M717592</link>
      <description>Thanks for the replies.</description>
      <pubDate>Fri, 07 Nov 2003 08:43:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/c-code-required/m-p/3113256#M717592</guid>
      <dc:creator>Nigel Green</dc:creator>
      <dc:date>2003-11-07T08:43:13Z</dc:date>
    </item>
    <item>
      <title>Re: C code required.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/c-code-required/m-p/3113257#M717593</link>
      <description>you can create the following script (not necessary to develop any C code).&lt;BR /&gt;&lt;BR /&gt;ls -lt $1 | tail -1&lt;BR /&gt;&lt;BR /&gt;name this script lsoldest, for instance, and give execute perimissions. After copying it to /usr/sbin or any other directory included in the path you can use&lt;BR /&gt;&lt;BR /&gt;#lsoldest &lt;DIR&gt;&lt;BR /&gt;&lt;BR /&gt;to obtain a full listing for the oldest file/directory under &lt;DIR&gt;&lt;/DIR&gt;&lt;/DIR&gt;</description>
      <pubDate>Fri, 07 Nov 2003 09:06:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/c-code-required/m-p/3113257#M717593</guid>
      <dc:creator>Mister_Z</dc:creator>
      <dc:date>2003-11-07T09:06:54Z</dc:date>
    </item>
  </channel>
</rss>

