User Commands  - ls- (1)

NAME

ls-(1f) - [FUNIX:FILESYSTEM] list files in a directory (LICENSE:PD)

CONTENTS

Synopsis
Description
Options
Examples
Extended Sqlite Example
Author
License

SYNOPSIS

ls- [ --all][ --fmt DATE_FORMAT] [ --long| --csv] [pathnames]

ls- --version|--help

DESCRIPTION

Given a directory name list files in the directory

OPTIONS

pathnames
  name of directories or pathnames to display contents of. Defaults to current directory.
--all,a
  show hidden files (files beginning with ".").
--long,l
  long listing. Date shown is the date of last modification.
--fmt,f FMT
  alternate format for date and time. Calls fmtdate(3f).
--csv generate output as a CSV file. Filenames should not have ,"’ characters in them. Very useful for use with sqlite3(1) and making a file that can be read into most spreadsheets,
--help display command help and exit
--version
  output version information and exit

EXAMPLES

Sample command lines ...

     ls-
     ls- . /tmp -l

# add Unix Epoch date ls- -l -fmt year-month-day hour:minute:second epoch

# use the phase of the moon for the date ls- -l -fmt %p %P

# sort by file age with newest at the bottom ls- -l -fmt %a|sort -k 8hr|column -t

EXTENDED SQLITE EXAMPLE

The CSV output can often just be read by spreadsheets. Typically the file suffix ".csv" is required. Assuming you have bash(1), sqlite3(1) and column(1) on your platform this is an example script that shows how SQL statements can be used to generate many kinds of file reports (number of bytes owned by users, number of files, sorting, ... It assumes you or somone who will assist you is familiar with SQL and sqlite3(1):

   #!/bin/bash
   #@(#) list files accessed today in current directory
   export SCRATCH=/tmp/$(uuidgen).csv   # create scratch file name
   trap "/bin/rm -f $SCRATCH" EXIT      # ensure scratch file is removed
   ls- -csv -- . |tail -n +2>$SCRATCH   # generate CSV file
   (
   # read CSV file into an SQLite file and generate a report as HTML table
   sqlite3     -cmd ’CREATE TABLE directory("Inode_number" INT,
      "Number_of_blocks_allocated" INT,
      "File_mode" TEXT,
      "Number_of_links" INT,
      "Owner" TEXT,
      "Groupname" TEXT,
      "File_size" INT,
      "Last_access" DATE,
      "Last_modification" DATE,
      "Last_status_change" DATE,
      "Pathname" TEXT );’       -cmd ’.mode csv’       -cmd ".import $SCRATCH directory" <<\end_of_file
   -- .schema
   .mode column
   .header on
   SELECT Pathname, File_mode, Owner, Groupname, File_size,
   strftime(’%Y-%m-%d %H:%M:%S’, Last_access) as "Last_Access"
      FROM directory
      WHERE DATE(’now’, ’start of day’) < Last_access
      ORDER BY Pathname ASC;
   end_of_file
   )| column -t -s ’|’
   exit

AUTHOR

John S. Urban

LICENSE

Public Domain


Nemo Release 3.1 ls- (1) February 23, 2025
Generated by manServer 1.08 from 33bfaf79-ef96-411c-8349-43f8fe72c6b7 using man macros.