Difference between revisions of "Bash"

From rbachwiki
Jump to navigation Jump to search
 
(28 intermediate revisions by the same user not shown)
Line 1: Line 1:
==Bash Scripting ==
==[[Scripts used on Servers]]==
==[[Useful bash commands]]==
==[[Tmux]]==


=== Create a Script that will resize an image to multiple sizes===
== Useful Command Line Utilities ==
#!/bin/bash
* [[RMLINT | RMLINT - Duplicate Finding cmd Tool]]
* [[RCLONE | Rclone syncs your files to cloud storage ]]
fn="testimage"
* [[NCDU | Ncdu Ncdu is a disk usage analyzer]]
* [[BTOP]]
for SIZE in 29 40 50 57 58 60 72 75 76 80 87 100 114 120 144 152 167 180 512 1024
* [[NTFY]]
do
    sips -Z $SIZE "${fn}.jpg" --out "${fn}${SIZE}.jpg"
done


<pre>
==[[Image Scripts]]==
 
==[[Script Course]]==
Brace Expansion {}, helps with repeated commands
==[[Centos OS | More Scripting]]==
 
==[[Sample Scripts]]==
touch {apple, banana, chery} // would create three filenames
==[[File Commands]]==
touch filename_{01..100} // will create 100 filenames
===[[Ubuntu File System Commands]]===
echo {A..Z} // prints A - Z
* find, copy, replace, rename
echo {1..10..3} // prints 1 - 10 step 3
==[[AWK Command]]==
touch {apple,banana,cherry}_{01..100}{w..d}
==[[Text File Commands]]==
 
* find and replace text in bulk
** Std Output
==[[BSD MAILX]]==
cp -v * /folder 1> success.txt 2> error.txt
==[[Shell Scripting]]==
 
Grep with awk
grep -i searchTerm filename.txt | awk {'print $12'} // will output the 12th thing on a line space delimited and only return that value
 
** Variables
Bash file
#!/bin/bash
a=hello
b="Good Morinng"
c=16
echo "$b I have $c apples."
 
output [Good Morning I have 16 Apples]
 
** Get Info from users
Bash file
#!/bin/bash
echo "Enter your name"
read name
echo "What is your password"
read pass
read -p "what is your fav animal " animal
echo name: $name, pass: $pass, animal: $animal // this is an inline prompt
</pre>
----
[[#Bash Scripting|Back To Top]]-[[Main_Page| Home]]

Latest revision as of 13:22, 15 June 2023