Skip to content

Commit 948365d

Browse files
authored
Adding Bash commands to content/command-line/conepts/bash.md (#4970)
* Initial branch commit, added basic Bash commands to Bash.md * cleaned up formatting for markdown * [Concept Expanded] Aligned new bash.md content to match styling guide. * Update bash.md * Update bash.md * Update bash.md * Update bash.md * Update bash.md * Update bash.md * Update bash.md * Update bash.md * Review changes ---------
1 parent 157836b commit 948365d

File tree

1 file changed

+112
-0
lines changed
  • content/command-line/concepts/bash

1 file changed

+112
-0
lines changed

content/command-line/concepts/bash/bash.md

+112
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,115 @@ Apple macOS featured Bash as the default from 2003 with OS X Panther (version 10
4343
### Windows
4444

4545
Bash is not the default shell for Windows operating systems, but it can be enabled through the Windows Subsystem for Linux (WSL). This runs a Linux environment without the need for a [virtual machine](https://www.codecademy.com/resources/docs/general/virtual-machines).
46+
47+
### Bash Terminal Commands
48+
49+
The basic terminal commands for navigating and manipulating directories and files are as follows -
50+
51+
#### `cat` Command
52+
53+
The `cat` (short for _concatenate_) command is used to display the contents of a file in the terminal. It can also be used to concatenate multiple files into one. By default, it outputs the contents of the file(s) to the terminal.
54+
55+
```shell
56+
# Display the contents of a file
57+
cat filename.txt
58+
59+
# Display the contents of multiple files
60+
cat file1.txt file2.txt
61+
62+
# You can also use redirection to concatenate files into a new file
63+
cat file1.txt file2.txt > combined.txt
64+
```
65+
66+
### Navigation Commands
67+
68+
In Bash, navigation commands are used to move through directories and the file system efficiently.
69+
70+
#### Print Working Directory Command
71+
72+
Use the `pwd` command to display the current directory -
73+
74+
```shell
75+
pwd
76+
```
77+
78+
#### List Command
79+
80+
Use the `ls` command to list the contents of the current directory -
81+
82+
```shell
83+
# To list the contents of the current directory
84+
ls
85+
86+
# Use the -l argument to get a detailed list with more information
87+
ls -l
88+
```
89+
90+
> **Note:** If `ls` is used with the `-a` argument, it also shows hidden files.
91+
92+
#### Change Directory
93+
94+
The `cd` command is used to change directories -
95+
96+
```shell
97+
# To go to a specific directory
98+
cd directoryPath
99+
100+
# To go to the Previous Directory
101+
cd -
102+
103+
# To go up one directory level
104+
cd ..
105+
```
106+
107+
### Directory Management
108+
109+
In Bash, directory management involves creating, deleting, moving, copying, and manipulating directories within the file system.
110+
111+
#### Make a New Directory
112+
113+
To create a new directory, use the `mkdir` command followed by the new directory name -
114+
115+
```shell
116+
mkdir newDirectoryName
117+
```
118+
119+
#### Remove a directory
120+
121+
To delete a directory, use the `rmdir` command with the directory's name -
122+
123+
```shell
124+
rmdir directoryName
125+
```
126+
127+
### File Management
128+
129+
In Bash, file management involves creating, deleting, moving, copying, and manipulating files within the file system.
130+
131+
#### Create a new file
132+
133+
To create a new empty file, use the `touch` command followed by the file name -
134+
135+
```shell
136+
touch filename.txt
137+
```
138+
139+
#### Remove a file
140+
141+
To delete a file, use the `rm` command with the file name or file path -
142+
143+
```shell
144+
rm filename.txt
145+
```
146+
147+
#### Rename or move a file
148+
149+
To rename a file or move it to a new location, use the `mv` command -
150+
151+
```shell
152+
# Rename the file (original name is the first argument, new name is the second)
153+
mv oldFileName.txt newFileName.txt
154+
155+
# Move a file to a different directory (source path is the first argument, destination path is the second)
156+
mv sourceDirectory/filename.txt destinationDirectory/filename.txt
157+
```

0 commit comments

Comments
 (0)