ALL LINUX
  • Linux 4 Network Engineers
  • Introduction
    • Untitled
  • LINUX - "HOW-TO-DO"
    • SYSADMIN
      • MONITORING
        • Stress Testing Linux
      • DEBIAN APT
      • DISK
        • Directory Share - NFS,CIFS
        • LOGICAL VOLUME MANAGEMENT (LVM)
        • FILE SYSTEMS
          • ZFS
      • FIND & DU
      • SECURITY
        • SSH Open Format
      • USERS
        • Accounts, Groups etc
        • Assess User Activity
    • SCRIPTING & TEXT EDIT
      • BASH SCRIPTING & PROJECTS
        • 1) How to Build a Bash Script
        • 2) Variables & Shell Expansions
        • 3) Processing Command Lines
        • 4) Requesting User Input
      • VIM Editor
        • Vim Tips
      • GREP, EGREP & REGEX
        • REGEX
        • REGEX2
        • NINJA-REGEX
      • SED and AWK
  • Containers
    • MULTIPASS
    • LXD LXC
    • KUBERNETES (K8's)
  • FOSS
    • CUMULUS LINUX
      • Fundamentals
        • Cumulus Linux Introduction
        • Cumulus Linux Architecture
        • Cumulus VX
        • Initial Setup
      • NCLU
  • Linux Prof Inst Cert [LPIC-1]
    • LPIC 1
      • CH1-Linux Command-Line Tools
        • Work on the Command Line
        • Streams, Pipes and Redirects
          • Text Streams Using Filters
        • Search Text Files - Regular Expressions
        • Basic File Editing
      • CH2-Managing software and Processes
      • Ch3-Configuring Hardware
      • Ch4-Managing Files
      • Ch5-Booting, Initialising and Virtualising Linux
Powered by GitBook
On this page

Was this helpful?

  1. LINUX - "HOW-TO-DO"
  2. SCRIPTING & TEXT EDIT
  3. BASH SCRIPTING & PROJECTS

4) Requesting User Input

Positional Parameters

The shell assigns numbers called 'positional parameters' to each command line argument that is entered. For example we use the cd (change directory to whichever directory you want to move to) or cp (type the file you want to copy and where you want to copy that file to). The feature that makes this possible is "positional parameters"

Example 1: Lets create a bash script "positional_script.sh #!/bash/bin echo "My name is $1" echo "Hy home directory is $2" echo "My favourite colour is $3" chmod 744 positional_script.sh

$#> positional_script.sh John $HOME blue

My name is John My home directory is /home/john My favourite colour is blue

The $1 $2 and $3 refer to the first, second and third command line arguments given to the script

Test bed
Previous3) Processing Command LinesNextVIM Editor

Last updated 3 years ago

Was this helpful?