Main index

Introducing UNIX and Linux


Introduction to shells

Overview
Why do we need a shell?
Shell syntax
      Types of shell command
      Simple commands
      Pipelines
      Grouping commands
      Exit status
      List commands
Arithmetic
      Operators and functions
Making decisions
      The 'test' statement
            Operators used by 'test'
      The 'if' statement
Loops
      'For' loops
      'While' and 'until' loops
Searching for files
      Arguments to 'find'
Formatted output
      Arguments to 'printf'
Passing information to scripts
      Scripts with arguments
      Parameter expansion
Summary
Exercises

Answer to chapter 7 question 1

Use find followed by a tilde (the current directory) to select files from the current directory, and argument -print to list them. Other arguments are needed to perform the selection, and as there are many possible arguments you should read the manual page. Argument -type f selects regular files. To check on the file size, argument -size followed by an integer n selects all files whose size is between (n-1) and n blocks of 512 bytes. The command becomes:

find ~ -type f -size 1 -print


Copyright © 2002 Mike Joy, Stephen Jarvis and Michael Luck