Linux Commands 3 - PowerPoint PPT Presentation

1 / 11
About This Presentation
Title:

Linux Commands 3

Description:

Usage: source file [arguments] Read and execute the ... Usage: test condition ... finding particular groups of files (numerous examples follow this description) ... – PowerPoint PPT presentation

Number of Views:89
Avg rating:3.0/5.0
Slides: 12
Provided by: sudip1
Category:
Tags: commands | linux

less

Transcript and Presenter's Notes

Title: Linux Commands 3


1
Linux Commands (3)
  • Sudipto Das
  • CS 60 Discussion
  • Feb 16, 2007

Some points taken from http//www.oreillynet.com/l
inux/cmd/
2
Contents
  • source
  • test
  • cut
  • find
  • grep
  • tar
  • gzip and gunzip

3
source
  • Usage source file arguments
  • Read and execute the lines of a file.
  • file does not need to be executable but must
    reside in a directory search by PATH
  • Any arguments are passed as arguments to the file
    being executed
  • The return status of the command is the return
    status of the last instruction executed in the
    file

4
test
  • Usage test condition
  • Evaluate a condition and, if the value is true,
    return 0, otherwise return a non zero exit status
  • Condition can be constructed in a variety of ways
  • File Conditions
  • -a file file exists
  • -d file file is a directory
  • -e file file exists
  • -f file file is regular
  • -r file file is readable

5
test
  • String Conditions
  • -n s1 String s1 has non zero length
  • -z s1 String s1 has 0 length
  • s1 s2 s1 and s2 are identical
  • string string is not null
  • Integer Comparisons
  • n1 -eq n2 n1 equals n2
  • n1 -ne n2 n1 does not equals n2
  • n1 -gt n2 n1 greater than n2
  • n1 -lt n2 n1 less than n2
  • n1 -le n2 n1 less or equals n2

6
cut
  • Usage cut options files
  • Cut out selected columns or fields from one or
    more files.
  • In the options, list is a sequence of integers.
  • A comma is used between separate values, and a
    hyphen is used to specify a range.
  • Options
  • -d specify the delimiter
  • -f specify the field to cut
  • -c specify the column number

7
find
  • Usage find pathnames conditions
  • An extremely useful command for finding
    particular groups of files (numerous examples
    follow this description).
  • find descends the directory tree beginning at
    each pathname and locates files that meet the
    specified conditions.
  • The default pathname is the current directory
  • The most useful conditions include
  • -name and -type (for general use),
  • -exec and -size (for advanced use), and
  • -mtime and -user (for administrators).

8
grep
  • Usage grep options pattern files
  • Search one or more files for lines that match a
    regular expression pattern
  • Options
  • -a Don't suppress output lines with binary
    data, treat as text.
  • -c Print only a count of matched lines. With -v
    option, count non-matching lines
  • -e pattern search for the pattern in the file
  • -n print the line numbers with the matching
    lines
  • -r search recursively
  • -v invert matches

9
tar
  • Usage tar options tarfile other-files
  • Copy files to or restore files from an archive
    medium.
  • If any of files are directories, tar acts on the
    entire subtree
  • Options
  • -c create an archive
  • -x extract an archive
  • -v verbose
  • -r append at the end of an existing archive
  • -z use gzip while archiving or extracting

10
gzip and gunzip
  • Usage
  • gzip options files
  • gunzip options files
  • Zip or unzip the files.
  • Options
  • -v verbose
  • -r recursive
  • -f force zipping or unzipping

11
Pipelining Commands
  • Output of one command becomes the input of the
    next command
  • Pipelining done by using the operator
  • Use the power of Linux commands to do great jobs
Write a Comment
User Comments (0)
About PowerShow.com