Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Using Multiple Utilities in Scripts and Accessing and Changing Previous Commands | CS 333, Study notes of Computer Science

Material Type: Notes; Class: UNIX Operating Sys Fundamental; Subject: Computer Science; University: University of Alabama - Birmingham; Term: Fall 2005;

Typology: Study notes

2009/2010

Uploaded on 04/12/2010

koofers-user-iaf
koofers-user-iaf 🇺🇸

4.3

(2)

10 documents

1 / 5

Toggle sidebar

Related documents


Partial preview of the text

Download Using Multiple Utilities in Scripts and Accessing and Changing Previous Commands | CS 333 and more Study notes Computer Science in PDF only on Docsity! 1 CS-344 - Unix Operating System Fundamentals Lecture 5 Using Multiple Utilities in Scripts and Accessing and Changing Previous Commands Based on slides created by Dr. Bangalore for the Spring 2005 offering of the course 9/15/2005 3 D e p a rt m e n t o f C o m p u te r a n d I n fo rm a ti o n S c ie n c e s U A B Shell Scripts (I)  Enables execution of complex tasks by using multiple commands in a single file  .bashrc or .bash_profile are such examples  Create simple script using any editor echo "Welcome" $USER echo "Today's date is: " date | cut -d' ' -f2-3 echo "You are logged in to: " hostname echo "There are" who | wc –l echo "user(s) currently logged in" echo "Your PATH is set to the following directories:" echo $PATH | tr ‘:’ ‘\n’ 2 9/15/2005 4 D e p a rt m e n t o f C o m p u te r a n d I n fo rm a ti o n S c ie n c e s U A B Shell Scripts (II)  To execute a script:  The script must have execute permission  File permissions can be set using “chmod”  or  Use source script_name 9/15/2005 5 D e p a rt m e n t o f C o m p u te r a n d I n fo rm a ti o n S c ie n c e s U A B Creating a complex script  Read a file – myfile.in  Output to the screen the total number of unique words  Output the list of unique words to the file words.out along with the number of times each word appears ordered with the most-used words listed first  Solution: tr -d '?."!:,;' < myfile.in | tr 'A-Z' 'a-z' | tr ' \t' '\n\n' \ | sed '/^$/d' \ | sort | uniq -c | sort -rn \ | tee words.out | wc -l 9/15/2005 6 D e p a rt m e n t o f C o m p u te r a n d I n fo rm a ti o n S c ie n c e s U A B Algorithm  Delete punctuation characters  Convert all characters to lowercase  Move each word to a separate line  Remove blank lines (if any)  Sort the lines  Remove duplicates  Compute word frequency and output to file  Compute the total number of unique words
Docsity logo



Copyright © 2024 Ladybird Srl - Via Leonardo da Vinci 16, 10126, Torino, Italy - VAT 10816460017 - All rights reserved