Results 1 to 5 of 5

Thread: Shell Scripting questions

  1. #1
    Geek_Guest
    Guest

    Shell Scripting questions

    Question asked by straakaatt9

    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?


  2. #2
    Junior Member
    Join Date
    May 2007
    Answers
    4

    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.


  3. #3
    Junior Member
    Join Date
    Jan 2007
    Answers
    5

    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 Originally Posted by Geek_Guest View Post
    Question asked by straakaatt9

    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?



  4. #4
    Junior Member
    Join Date
    Sep 2007
    Answers
    1

    Shell Scripting questions

    Write the commands to remove all the space characters stored in the shell variable text.


  5. #5
    Junior Member
    Join Date
    Sep 2007
    Answers
    10

    Re: Shell Scripting questions

    Quote Originally Posted by daxeshpatel View Post
    Write the commands to remove all the space characters stored in the shell variable text.
    text="hai this is for testing"
    echo "$test"|tr " " "\0"
    output
    haithisisfortesting


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Applying for a job can be a stressful and frustrating experience, especially for someone who has never done it before. Considering that you are competing for the position with a at least a dozen other applicants, it is imperative that you thoroughly prepare for the job interview, in order to stand a good chance of getting hired. That's where GeekInterview can help.
Interact