Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions q1.sh
Original file line number Diff line number Diff line change
@@ -1 +1,48 @@
<<<<<<< HEAD
This is q1 answer
=======
#a
echo "a.the number of rows are:"
cat aliceinwonderland.txt | awk 'END{print NR}'

#b
echo "b.the number of Alice shown:"
cat aliceinwonderland.txt | awk '/ Alice / {count++} END{print count}'

#c
cat aliceinwonderland.txt |
awk '
{
for ( i=1 ; i <= NF; i++ )
count [$i]++
}
END {
for (c in count)
if (count[c] == 1)
print c
} '

#d
cat aliceinwonderland.txt | awk '
{
for (i=1 ; i<=NF ; i++)
count[$i]++
}
END {
for (c in count)
print count[c],c
}' | sort -nr | head -5

#e
cat aliceinwonderland.txt |
awk '{
for (i = 1; i <= NF; i++)
{
counterlen += length($i)
countersum++
}
}
END {
print counterlen / countersum
}'
>>>>>>> dbc7ccf (q1 and q2 anwser)
15 changes: 15 additions & 0 deletions q2.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#a
cat sherlockholmes.txt | sed -n '/Sherlock\|Holmes/p' | wc -l

#b
cat sherlockholmes.txt | sed 's/[[:space:]]/\n/g' | sed -n -E '/(Sherlock|Holmes)/p' | wc -l

#c
cat sherlockholmes.txt | sed -n 's/^.\{70,\}$/"Long line"/'

#d
cat sherlockholmes.txt | sed -E 's/[[:upper:]][[:lower:]]{1,}[[:space:]]+[[:upper:]][[:lower:]]{1,}/Adi Hirsch/g'

#e
cat sherlockholmes.txt | sed -E 's/\(([^()]*)\)/[\1]/g'