One line command - bash
Not sure if this is the right section for this question
I need a one-liner for this task: print the scripts that are being run at the begining of the current runlevel. so fare I have runlevel | cut -f 2 -d " " Next, I need a ls, but I don't know how to set the path parameter to /etc/rcx.d/ where x is the number that is displayed when using the runlevel | cut command. Please help. |
Try something like
Code:
rlvl=$(runlevel | cut -f 2 -d " ") |
You can take the result of a command and use it in another using either `backticks` or $(like this). I favour the $() syntax because it less likely to lead to a mistake (i.e. using the wrong type of quote), and is nestable.
The programs which will be run for a given runlevel are the ones with S at the start of the file name, so if you want to list the files which are executed, you can do it like this: Code:
ls /etc/rc$(runlevel | cut -d" " -f2).d/S* |
thanks. It works just fine
|
All times are GMT -5. The time now is 10:13 PM. |