The attempts at a solution (include all code and scripts):
Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course):
San Francisco City College. Professor: Aaron Brick
Note: Without school/professor/course information, you will be banned if you post here! You must complete the entire template (not just parts of it).
If you can follow and understand following code, you should be able to easily adjust it for you needs with only few minor modifications. Hope it helps.
Simple for loop:
for shell in bash ksh tcsh
do
echo "$shell"
done
Assigning value to variable in the for loop:
for shell in bash ksh tcsh
do
path=$(which "$shell")
echo "$shell: $path"
done
Column format, simplified, utilizing tabulator:
for shell in bash ksh tcsh
do
path=$(which "$shell")
echo -e "$shell\t$path" # you can exchange $shell and $path anytime
done
Column format, utilizing printf (for perfect alignment)
for shell in bash ksh tcsh
do
path=$(which "$shell")
# First column format: 5 chars left-aligned
# Second column format: 15 chars right-aligned
printf '%-5s %15s\n' "$shell" "$path"
done
Thank you..... But I have written the new command lines to get these output below. But I only want to pick out .bash .ksh and .zsh. Is the only command I can use here is grep? How do I use the grep command to get rid of the line that I don't want? So my output will only have 3 lines left.
Howsoever you created your output, pipe it through grep -E "bash|ksh|zsh" . If that is not specific enough, try to anchor the patterns, or extend them by meaningful items.