Cool to see these sorts of videos on yt. If you like sublime you might also like the editor Atom. It's opensource, actively developed, dark color scheme by default, etc. It even has the minimap feature as a package.
@khilanpatels4 жыл бұрын
just some extra info, $@ is all the arguments.
@moebius4359 жыл бұрын
The *shift* command shifts all arguments down 1 index. *"$1"* disappears, *"$2"* takes its place, *"$3"* takes *"$2*'s place, etc. It is useful to enclose the argument parsing code in a *until* loop which tests if *"$1"* is empty as its exit condition. Not going to argue against you though: as powerful as Bash is it isn't always the correct tool for large/complex jobs. *help shift* *help until*
@kamilkurzynowski38364 жыл бұрын
Yes and you could combine it with while loop to process all the arguments.
@kamilkurzynowski38364 жыл бұрын
I wish you luck using those fancy things like python, they are super nice when you can use them, that is true... It is good for programmers administering in small scale, as a sysadmin you'll be dealing with a lot of legacy machines and technologies, the more critical is your infrastructure is the more you'll be dealing with old tech (including things like mainframe if you work in some fintech). I'm now learning bash deeply, cause next to bare metal C it is the only language that is compatible with all machines in my working environment. Is it a hustle? Obviously, but the reward comes in the form of the toolbox that you can probably run even on your crockpot. Don't take it wrong, great video, but I wouldn't give to much hope for the young sysadmins starting their career in terms of easy to use/easy to learn tools.
@sorover1115 жыл бұрын
Can anyone help explain why the curly braces are used around line 17 .. Why can't it just be $1, $2, etc ?
@tutoriaLinux5 жыл бұрын
You could just just $1 and $2, although that could introduce quoting issues. Using string interpolation like "${1}" can avoid some of these potential issues.
@sorover1115 жыл бұрын
@@tutoriaLinux thanks man
@samuraijack59194 жыл бұрын
Bash Scripting 5 -- Arguments My Notes: When the program is started, the filename is in what variable (bash scripting) The 0 variable (that will be the name of our script) - If you try to echo an argument that does not exist, the terminal will give you... (bash scripting) a blank line back (bash will forgive you and not throw an error) - Does bash use Zero-indexing (Does it start counting from 0,1,2 or does it start from 1,2,3?) It does not use Zero-indexing, it starts from 1,2,3 Tell me if i missed anything. Be safe and have a great day.
@uuu123432 жыл бұрын
Shellscript does use Zero-indexing, its just that the zeroth position is like python - it is just the executable's filename itself. In this case, the scriptname
@prashantupadhyay60193 жыл бұрын
Great video How to provide file name as argument in bash script I want to sort csv file data. Please guide
@sumanth19897 жыл бұрын
I dont understand the part of running the file, can u elaborate on which directory you have saved arguments.sh and how u run it in the bash directory? Can u also automate running this script using the crontab like u explained in a previous video?
@AlDumbrava7 жыл бұрын
After he opened the terminal he was in ~ (his home directory). The first command he did was cd code/bash. So he's now in /home/dave/code/bash/ directory. From there he tried to run the argument.sh script but it didn't have the right permissions so he executed the chmod +x to fix that. He ran the file by simply calling (maybe opening is a better word) it (once it has execute permissions you can call the script from anywhere) ./arguments.sh means run the file arguments.sh which is located in the current directory. He can also run this file from anywhere by specifying the absolute path: /home/dave/code/bash/arguments.sh Yes you can crontab your scripts. Instead of having the echo "Hello world" >> ~/mylog.txt as the command to be run at your specified time, you would specify the absolute path to your script.
@musicmansuperman7 жыл бұрын
The 'nounset' option for your shell is set to "off". That's why your echo command didn't throw an error. Also, I was expecting a discussion of the getopts utility. Can you cover that?
@youneschoukri11845 жыл бұрын
cannot source my .sh file to get the output of the variable it's saying bash: Hello: command not found... Do I need to install source or something? Any help please?
@Bud_Lightyear8 жыл бұрын
I was in tune until this video. Do you have any other videos that go further in depth on Arguments?
@HigherPlanes9 жыл бұрын
I'm still trying to understand this stuff I just can't wrap my mind around it. if I just echo $0 in a terminal I get back my current shell. What's a simple example of using $1 in a command?
@tutoriaLinux9 жыл бұрын
+HigherPlanes This video applies mostly to scripts which have been saved in their own file, and are being run from your shell. Like you mentioned, 'echo $0' (the name of the script) will just return the name of your shell if you run it from an interactive shell session. Since your shell session isn't a program that was run with arguments, $1, $2, ...$n will be empty values. If you have that same statement in a file, though, and then run that file from your shell, you'll get the filename echoed out to you.
@HigherPlanes9 жыл бұрын
+tutoriaLinux Okay, that helps. I'm trying out some examples hopefully it'll sink in.
@bilalsajid967 жыл бұрын
can you name some books which are available online good for bash scripting!
@tutoriaLinux7 жыл бұрын
This is all you need: tldp.org/LDP/abs/html/
@andreaaldrich40467 жыл бұрын
When I do the ourfilename part, the output I get is "-bash". This is making my crazy! What is wrong?
@andreaaldrich40467 жыл бұрын
Wait... I was putting ". a.sh" to execute it because that's how my teacher told us to do it, but when I put the forward slash it works... why is that?
@ArcaneFuror6 жыл бұрын
@@andreaaldrich4046 i know its been a year, but the answer lies in the previous video. The . Called that way is shorthand for source. And its applying it to the shell itself.
@Cespasbeau5 жыл бұрын
Now to digest, test and absorb. Then, take these arguments to HR and those who call for Federal deployment projects. Can't wait to see them {sick}.
@janzaibmbaloch54845 жыл бұрын
Cool!!!, why did everyone else make it look like a rocket science?
@TechnologyGeek776 жыл бұрын
line 17 should be: echo "The first ${num_arguments} arguments are ${1}, ${2}, ${3}."}
@piotrwln93486 жыл бұрын
If you suddenly have 4 arguments instead of 3, the last one won't be printed.
@souravsingha66968 жыл бұрын
thanks
@dinnerandashow3 жыл бұрын
"You hit the spot! ${1}, ${2}"
@dharmatejaable8 жыл бұрын
hey bro, bash arguments.... can u be more specific.. u just ran away with this..