-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInput Output command - echo | read | echo arguments
More file actions
59 lines (30 loc) · 1.27 KB
/
Copy pathInput Output command - echo | read | echo arguments
File metadata and controls
59 lines (30 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
*> Input Output Command for Shell Scripting
- echo - an output command for Shell
- read - takes Input from user on terminal and stores in variable
SYNTAX
>> read <var_name>
>> read var1 # takes input on terminal and stores in var1
>> read -p "Enter Something: " var1 # prompts message before taking input
- REPLY - default variable for read command
>> read -p "Enter: "
>> echo ${REPLY}
*> Input with Command Line Argument
- aka Positional Arguments
- Are the arguments/values specified at the command prompt while running commands/shell scripts.
Script-
<<<<
#!/usr/bin/bash
echo "$1" # first argument after running script
echo "$2" # Second argument
echo "$3" # third argument
<<<<
./<script.sh> 12 32 14 53 "sv a" vrd # values must be separated by spaces
$1 $2 $3 $4 $5 $6
- $0 - gives name of the Script itself
- we can use name of the script inside that script using $0
- ${>=(2 digit no.)} - to access arguments greater than 2 digit number, enter the number inside { } after $
- ${10} - returns 10th argument given on terminal
- $10 - returns values of '$1$0' together as an output.
- $# - returns number of arguments passed in terminal
- $@ - returns all the arguments passed
- $* - returns all the arguments passed