The Code Ive done so far:
#!/bin/bash
echo "Ramzan: May 13 2021"
echo "Diwali: Nov 04 2021"
echo "Christmas: Dec 25 2021"
mkdir ABCCompany
mkdir ABCCompany/HRDept
mkdir ABCCompany/FinanceDept
touch ABCCompany/HRDept/EmployeeDetails.txt
touch ABCCompany/FinanceDept/SalaryDetails.txt
cd ABCCompany/HRDept
FILE=EmployeeDetails.txt
if [[ -f $FILE ]]; then
echo "1 Tec101 Sathya permanent Active 1stApril2011" >> EmployeeDetails.txt
echo "2 Tec102 Laya permanent Active 14thJuly2008" >> EmployeeDetails.txt
echo "3 Tec103 Hari temporary Active 26thDec2010" >> EmployeeDetails.txt
echo "4 Tec104 Alex temporary Inactive 26thOct2015" >> EmployeeDetails.txt
echo "5 Tec105 Lisa temporary Inactive 15thMay2017" >> EmployeeDetails.txt
echo "6 Tec106 Jisha permanent Active 05thJan2020" >> EmployeeDetails.txt
else
echo "File Does not Exist"
fi
while read p; do
grep "Active" $p
done < $FILE
What I need to do:
I need to transfer all Text Lines with the world Active in it from EmployeeDetails to SalaryDetails I have tried every grep and it does not seem to work...
Forgive me im new to this.. Some guidance would be good
Output:
Ramzan: May 13 2021
Diwali: Nov 04 2021
Christmas: Dec 25 2021
grep: 1: No such file or directory
grep: Tec101: No such file or directory
grep: Sathya: No such file or directory
grep: permanent: No such file or directory
grep: Active: No such file or directory
grep: 1stApril2011: No such file or directory
grep: 2: No such file or directory
grep: Tec102: No such file or directory
grep: Laya: No such file or directory
grep: permanent: No such file or directory
grep: Active: No such file or directory
grep: 14thJuly2008: No such file or directory
grep: 3: No such file or directory
grep: Tec103: No such file or directory
grep: Hari: No such file or directory
grep: temporary: No such file or directory
grep: Active: No such file or directory
grep: 26thDec2010: No such file or directory
grep: 4: No such file or directory
grep: Tec104: No such file or directory
grep: Alex: No such file or directory
grep: temporary: No such file or directory
grep: Inactive: No such file or directory
grep: 26thOct2015: No such file or directory
grep: 5: No such file or directory
grep: Tec105: No such file or directory
grep: Lisa: No such file or directory
grep: temporary: No such file or directory
grep: Inactive: No such file or directory
grep: 15thMay2017: No such file or directory
grep: 6: No such file or directory
grep: Tec106: No such file or directory
grep: Jisha: No such file or directory
grep: permanent: No such file or directory
grep: Active: No such file or directory
grep: 05thJan2020: No such file or directory