Shell Scripting questions
[b]Question asked by straakaatt9[/b]
I'm just learning how to write shell scripts and I need your help in solving a couple of scripting questions: Here goes,
1. Write a command line that will count the number of daemon processes?
2. Write a command line that will display a sorted list of logged-in users using the sed command?
3. Write a script to remove all space characters stored in the shell variable called text, using the tr command.
4. Same as #3 using the sed command instead of the tr command?
5. Write script to count number of characters stored in shell variable called count=?
6. Write program to assign unique lines in the file called names to a shell variable called namelist?
Re: Shell Scripting questions
1) Process table in unix does not have any identification for the type of process. And the daemon process is nothing but the process running in a loop. So I do not think there is a way to list the daemon processes in a single command line.
5) echo $count|wc -c
I will work on other questions and get back.
Re: Shell Scripting questions
1. ps -eaf | wc -l
2. who | sort -k 3 (sed is stream editor , you can edit file using sort)
3. echo " This is Kunal ." | tr -d "[:space:]"
echo " This is Kunal ." | tr -d ' '
4. echo " this is kunal ." | sed 's/ *//g'
5. echo " This is Kunal ." | wc -c (c for character count and l for line count)
6. I cant understand your 6 question
[QUOTE=Geek_Guest;9732][b]Question asked by straakaatt9[/b]
I'm just learning how to write shell scripts and I need your help in solving a couple of scripting questions: Here goes,
1. Write a command line that will count the number of daemon processes?
2. Write a command line that will display a sorted list of logged-in users using the sed command?
3. Write a script to remove all space characters stored in the shell variable called text, using the tr command.
4. Same as #3 using the sed command instead of the tr command?
5. Write script to count number of characters stored in shell variable called count=?
6. Write program to assign unique lines in the file called names to a shell variable called namelist?[/QUOTE]
Shell Scripting questions
Write the commands to remove all the space characters stored in the shell variable text.
Re: Shell Scripting questions
[QUOTE=daxeshpatel;18115]Write the commands to remove all the space characters stored in the shell variable text.[/QUOTE]
text="hai this is for testing"
echo "$test"|tr " " "\0"
output
haithisisfortesting