[go: up one dir, main page]

0% found this document useful (0 votes)
48 views1 page

Script 7

The document provides a shell script to display login names that start with the letter 's'. It includes multiple methods to achieve this, such as using 'cut', 'grep', and 'awk'. The script prompts the user for a username and counts the occurrences of matching usernames.

Uploaded by

for11trade
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
48 views1 page

Script 7

The document provides a shell script to display login names that start with the letter 's'. It includes multiple methods to achieve this, such as using 'cut', 'grep', and 'awk'. The script prompts the user for a username and counts the occurrences of matching usernames.

Uploaded by

for11trade
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Script No .

Definition:
Write a shell script to display the login names that begin with ‘s’.
Script:
clear
echo "enter the username to search with"
read un
who |cut -d " " -f1 | grep $un
cnt=`who|cut -d " " -f1 |grep $un| wc -l`
echo $cnt users with username are $uname

OR
echo "Login names beginnin with 's' : "
#who | awk '$1 ~ /^s/'
who | awk '{ if ($1 ~ /^s/) print $1 }'

OR
who | grep s*

You might also like