add another hard disk on Fedora Linux

Paul Howarth paul at city-fan.org
Mon Nov 21 13:33:39 UTC 2005


Tim wrote:
> Tim:
> 
>>>Thanks, most informative...  I keep meaning to look into some of these
>>>things, but don't seem to get around to it.  For instance, the output of
>>>some commands isn't described.  It's obvious what some of the columns
>>>refer to in the output from ls (file names, permissions, etc.), but
>>>there's a few things in there I hadn't figured out.
> 
> 
> 
> James Wilkinson:
> 
>>info ls
> 
> 
> I keep forgetting about "info" files for some things that already have a
> "man" file (they're not always the same document in a different format).
> Though it still doesn't let me know if I can do one thing that I'd like
> to be able to do:  Format the output of ls in a specialised way.  The
> "ls" info file is only a bit more informative than the man page.
> 
> For example, on ye olde Amiga, I could do a task like most of the
> following, with one command line.  Only going as far as using a script
> to add in extras around it.
> 
> Task:  Listing a directory of pictures, with the intention of making an
> HTML index page with thumbnails, where you've one directory with the
> full size pictures, another with identically named thumbnails, and
> you're making a page that shows one (the thumbnails) and links to the
> other (the full sizes).
> 
> I used to do it by using the list files command, but formatting the
> output of the command to fit selected parts of it (filenames, and
> perhaps dates) in-between other pre-supplied text.  Rather like the old
> concatenation of strings in BASIC.
> 
> Running this list command with a directory name, once, would make a
> webpage for the entire collection of files.  Going as far as making a
> script with a few more commands just tidied up the thing (headings,
> footers, etc.).
> 
> Pseudo code example:
> 
> list inputfilepath "<a href='/images/" + outputfilename + "' title=' + outputfiledate +'><img src='/thumbnails/" + outputfilename + "'></a>" >> index.html
> 
> I presume that explains the sort of thing I'm trying to do in an
> understandable manner.

Something like this?

$ ls --full-time | awk 'NR == 1 { next } { printf "<a 
href=\"/images/%s\" title=%s><img src=\"/thumbnails/%s\"></a>\n", $9, 
$6, $9 }' >> index.html

(all one line)

> But I'm damned if I can think of a simple way of doing the same sort of
> thing in Linux.  I've looked at the "ls" documentation, and various
> add-ons for Apache, etc.  I can't see a way of using ls (directly), and
> gallery programs for Apache often make incredibly complex, and malformed
> HTML, or just really bad tables of images, etc.  i.e. They don't work in
> the way I want.
> 
> It's a relatively simple task, but I gave up trying to do it, for want
> of a starting point to how to do that sort of thing.  I imagine I'll
> have to do it by listing the directory, with and output of only
> filenames, one per line, then parsing the output with something else to
> add the extra bits.  Though I don't have a starting point to figure out
> how to do that.

Linux is full of tools for doing things like this. awk just happens to 
be my preference but lots of people would do it in perl.

Paul.




More information about the fedora-list mailing list