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
16 changes: 15 additions & 1 deletion q1.sh
Original file line number Diff line number Diff line change
@@ -1 +1,15 @@
This is q1 answer
#הדפיסו את מספר השורות בספר.
awk '{print NR, $0}' aliceinwonderland.txt | tail -1 | cut -f1 -d " "

#הדפיסו את מספר המופעים של המלה Alice) עם רווח לפני ואחרי) בספר.
awk '{count += gsub(/ Alice /, "")} END {print count}' aliceinwonderland.txt

# הדפיסו את כל המלים שחוזרות רק פעם אחת בקובץ. הגדרה: "מלה" היא מחרוזת בין רווחים
awk '{for (i=1; i<=NF; i++) print $i}' file.txt | sort | uniq -u

# הדפיסו את 5 המלים הנפוצות ביותר בספר (ניתן להשתמש גם בפקודות שאינן awk(.
tr -c '[:alnum:]' '[\n*]' < aliceinwonderland.txt | sort | uniq -c | sort -n | ta

# הדפיסו את האורך הממוצע של מלה בקובץ.
awk '{total_words += NF; for (i = 1; i <= NF; i++) total_length += length($i)} END {if (total_words > 0) print total_length / total_words}' aliceinwonderland.txt

15 changes: 15 additions & 0 deletions q2.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#[200~כתבו פקודה המדפיסה את מספר השורות בהן מופיעה המלה Sherlock או Holmes.
sed -n '/Sherlock\|Holmes/p' sherlockholmes.txt | wc -l

# כתבו פקודה המדפיסה את מספר הפעמים בהם מופיעה המלה Shelock או Holmes.
sed -n 's/.*\(Sherlock\|Holmes\).*/\1/gp' sherlockholmes.txt | wc -l

#כתבו פקודה שמוסיפה את המחרוזת ":Hello "בתחילת כל שורה
sed 's/^/Hello /' sherlockholmes.txt

#replace full name by my name
sed -E 's/\b[A-Z][a-zA-Z]{1,} [A-Z][a-zA-Z]{1,}\b/Maya/g' sherlockholmes.txt

#כתבו פקודה המחליפה את כל המשפטים שבתוך סוגריים עגולים למשפטים בתוך סוגריים מרובעים.
sed -E 's/\(([^()]*)\)/[\1]/g' sherlockholmes.txt