Mock System Commands
System Commands :
Question 1
Version 1
cat Pincode_info.csv | cut -d "," -f 5 | egrep "(.).*\\1" | wc -l
Version 2
cat Pincode_info.csv | grep -o "[0-9]*" | sed -E 's/0/k/2' | sed -E 's/1/k/2' | sed -E
's/2/k/2' | sed -E 's/3/k/2' | sed -E 's/4/k/2' | sed -E 's/5/k/2' | sed -E 's/6/k/2'
| sed -E 's/8/k/2' | sed -E 's/9/k/2' | sed -E 's/7/k/2' | grep k |wc -l
Question 2
cut -d "," -f 9 Pincode_info.csv > final.txt
cat final.txt | awk '\\''{
arr[$0]++
}
END{
for(a in arr) {
printf("%s:%s\\n",a,arr[a])
}
}'\\''
Question 3
ln /encryption/two-level/binary/positive-offset/encoding-key ek
Question 4
Mock System Commands 1
grep -f result map | cut -d " " -f 2 | xargs grep "INVESTMENT" | cut -d " " -f 2 | cu
t -c 2- > result.txt ;
sum=0
while read -r line
do
(( sum += line ))
done < result.txt
echo $sum
Question 5
BEGIN{
FS=" "
cost=0
}
{
arr[$1]+=$2
}
END{
for(i in arr){
print i, arr[i]
}
Question 6
#!/usr/bin/awk -f
BEGIN {FS = ","
leave_sum_1997 = 0
leave_sum_1998 = 0
leave_sum_1999 = 0
leave_sum_2000 = 0
leave_count_1997 = 0
leave_count_1998 = 0
leave_count_1999 = 0
leave_count_2000 = 0
Final_Avg_1997 = 0
Final_Avg_1998 = 0
Final_Avg_1999 = 0
Final_Avg_2000 = 0
Mock System Commands 2
}
{
year = substr($1,2,4);
if (year == 1997)
{
leave_sum_1997 = leave_sum_1997 + $3
leave_count_1997++
}
if (year == 1998)
{
leave_sum_1998 = leave_sum_1998 + $3
leave_count_1998++
}
if (year == 1999)
{
leave_sum_1999 = leave_sum_1999 + $3
leave_count_1999++
}
if (year == 2000)
{
leave_sum_2000 = leave_sum_2000 + $3
leave_count_2000++
}
}
END {
if (leave_count_1997 !=0){Final_Avg_1997 = leave_sum_1997/leave_count_1997}
if (leave_count_1998 !=0){Final_Avg_1998 = leave_sum_1998/leave_count_1998}
if (leave_count_1999 !=0){Final_Avg_1999 = leave_sum_1999/leave_count_1999}
if (leave_count_2000 !=0){Final_Avg_2000 = leave_sum_2000/leave_count_2000}
print int(Final_Avg_1997)
print int(Final_Avg_1998)
print int(Final_Avg_1999)
print int(Final_Avg_2000)
Question 7
sed 's/delta/gamma/2i' input.txt
Mock System Commands 3
Question 8
s/^"""\\(.*\\)"""/#\\1/
/"""/,/"""/ {s/\\(.*\\)/#\\1/;s/"""//}
/^#$/d
Mock System Commands 4