├── LICENSE └── README.md /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 YASH YADAV 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

Guide for BASH Scripting

2 | 3 |

4 | 5 |

6 | 7 | This repository contains a walk-through guide required for you to start BASH-Scripting 8 | 9 | # Prerequisites 10 | 11 | To use this repository, you need the have a linux installed on your system. 12 | >For windows users --->Use WSL (windows subsystem for linux). 13 | 14 | ## What is BASH? 15 | **The main creator of Bash is Brian Fox, who started coding it in 1988 for the GNU Project.**
16 | To understand it, 17 | imagine Bash as a translator. Instead of clicking buttons and menus, you tell it what you want to do by typing simple commands. It then translates those commands into actions your computer can understand. 18 | 19 | Think of it like a super cool assistant: 20 | 21 | Need to copy a file? Tell Bash, and it'll do it in a snap. 22 | Want to open a website? Just ask Bash, and it'll launch your browser. 23 | Feeling lazy and want to rename all your cat pictures at once? Bash can write a quick script to do it for you! 24 | 25 | No fancy mouse clicks: Learning a few commands opens up a whole world of possibilities. 26 | Like building puzzles? Scripting with Bash is like putting little commands together to make cool things happen. 27 | Get things done faster: Save time by automating repetitive tasks. 28 | # Basic Commands 29 | pwd: `pwd` command is used to print present working directory, it returns the directory where you are present. 30 | ``` 31 | pwd 32 | ``` 33 | cd: `cd` command is used to surf through directories (directories are like folders and files) 34 | ``` 35 | cd [directory name] 36 | ``` 37 | this command will direct you into your [directory name] 38 | For example :To move into Desktop 39 | ``` 40 | cd Desktop 41 | ``` 42 | ls: `ls` command is used to list all directories or files inside that directory 43 | ``` 44 | ls [filename] 45 | ``` 46 | For example,to see all directories in desktop 47 | ``` 48 | ls Desktop 49 | ``` 50 | mkdir: it is used to make new directory 51 | ``` 52 | mkdir [foldername] 53 | ``` 54 | For example, you want to make a folder named "frontend.txt" 55 | ``` 56 | mkdir frontend 57 | ``` 58 | If you want to create new folder "frontend" and want to be inside this directory also ,then use `&&` 59 | ``` 60 | mkdir frontend && cd frontend 61 | ``` 62 | touch: it creates an empty file and it also use to update time-stamps. 63 | ``` 64 | touch [filename] 65 | ``` 66 | For example, you want to create a new file named name.txt 67 | ``` 68 | touch name.txt 69 | ``` 70 | To update time-stamps use `touch -t YYYYMMHHmm.ss [filename].txt` 71 | here, 72 |
y-year 73 |
M-month 74 |
H-hour 75 |
m-minutes 76 |
s-seconds 77 |
78 | For example, to update time-stamp of name.txt 79 | ``` 80 | touch -t 202402011200.00 name.txt 81 | ``` 82 | cat: to prints the contents inside the directory 83 | ``` 84 | cat [directory] 85 | ``` 86 | For example, to view content inside name.txt 87 | ``` 88 | cat name.txt 89 | ``` 90 | cp: its copy-paste, used to create a duplicate of specified files or directories in the destination location. 91 | ``` 92 | cp [options] [source] [destination] 93 | ``` 94 | For example, you want to make a copy of name.txt to a self made folder frontend 95 | ``` 96 | cd Desktop 97 | cp name frontend 98 | ``` 99 | (for copying file ,we don't need any option, but for moving folder we need `-r` as a option)
100 | >Q) What if [destination] is not made previously?
Ans: It will create it itself on your present directory 101 |
102 | mv: It is used to move directories from one location to another location.
103 | 104 | >Q) Can you rename a directory using `mv`?
Ans) ofcourse! By moving a directory into itself it's name will be over-written ,thus renamed 105 |
106 | 107 | ``` 108 | mv [options] [source] [destination] 109 | 110 | ``` 111 | For example, you want to move file named "name" to a new folder named "new". 112 | ``` 113 | mkdir new 114 | mv name new 115 | ``` 116 | ***If you are not giving options ,it doesn't mean command will not work, it's just it will work without handling them properly or avoid special handling.*** 117 | ## Vim 118 | 119 |
What is Vim ?
120 | Vim is a Unix text editor that's included in Linux, BSD, and macOS. It's known for being fast and efficient, in part because it's a small application that can run in a terminal, but mostly because it can be controlled entirely with the keyboard with no need for menus or a mouse. 121 |
122 | Vim is also commonly referred to as Vi because when it was written by Bill Joy in the late 1970s, it was short for visual editor. 123 |
Some Basic Vim commands
124 | vim: `vim` command is used to open file in vim editor 125 | 126 |
127 | 128 | ``` 129 | vim [filename] 130 | 131 | ``` 132 | For example, to open file named name. 133 | 134 |
135 | 136 | ``` 137 | vim name 138 | 139 | ``` 140 | Press `i` to enter insesrt mode in vim and can make changes.There are several modes in vim like Normal modes, Visual modes, Command-line mode,Ex mode. 141 | 142 |
143 | After writing, you can exit vim, using `ESC` + `:` ,then type 144 |
145 | q to exit without saving
146 | wq to exit with saving 147 |
148 | "!" before w and wq to imply forceful action ,like !wq and q. 149 | 150 | 151 | 152 | 153 | 154 | **For vim cheat-sheet ,click here** 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | --------------------------------------------------------------------------------