Update OS/bash/Week2/answers.md

This commit is contained in:
Aadit Agrawal 2025-01-14 15:17:50 +05:30
parent 277bd63efa
commit c9e281a068

View File

@ -1,24 +1,41 @@
## OS Lab - Week2 ## OS Lab - Week2
Q2. Q2. (* finds all the files in the folder with exactly two characters)
- `grep -E '^..$' *` (finds all the files in the folder with exactly two characters) ```bash
- `grep '^[A-Z]' *` grep -E '^..$' *
- `grep '\.$' *` grep '^[A-Z]' *
- `grep ' ' *` grep '\.$' *
- `grep '[0-9]' filename > outputfile` grep ' ' *
grep '[0-9]' filename > outputfile
```
Q3. - `grep -c "ICT" ITStudents.txt` Q3.
- `sed 's/:IT:/:Information Technology:/g' students.txt > ITStudents.txt` ```
- `sed awk -F: '$1 == "1234" { avg = ($6 + $7 + $8) / 3; print avg }' students.txt` grep -c "ICT" ITStudents.txt
- `awk 'NR==1 { print toupper($0) } NR>1 { print }' students.txt` sed 's/:IT:/:Information Technology:/g' students.txt > ITStudents.txt
sed awk -F: '$1 == "1234" { avg = ($6 + $7 + $8) / 3; print avg }' students.txt
awk 'NR==1 { print toupper($0) } NR>1 { print }' students.txt
```
Q4. - `grep -rl "MIT" . | xargs sed -i 's/MIT/Manipal Institute of Technology/g'` Q4.
```bash
grep -rl "MIT" . | xargs sed -i 's/MIT/Manipal Institute of Technology/g'
```
Q5.
```bash
find . -type f -name '*[0-9]*' -exec wc {} +
```
Q5. - `find . -type f -name '*[0-9]*' -exec wc {} +` Q6.
```bash
for i in {1..5}; do wc example.txt & done
```
```bash
Q6. - `for i in {1..5}; do wc example.txt & done` pkill wc
- `pkill wc` ```