Skip to contents

View the corresponding bash.Rmd file to learn more about how this page was generated.

Set a variable

$ NAME=$(whoami)

Spread a pipeline over multiple lines

$ seq 100 |
> grep 3 |
> wc -l
19

Retrieve a value

$ cowsay "I am g${NAME}"
 ____________
< I am groot >
 ------------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||

Command substitution

$ echo "CRAN has $(
>   curl -sL cran.r-project.org/web/packages/available_packages_by_date.html |
>   grep "index.html" |
>   wc -l
> ) packages"
CRAN has 20632 packages

Take a screenshot of top

$ top

After two seconds we see the following screen:

top - 09:30:52 up 21:21,  0 users,  load average: 0.12, 0.05, 0.01              
Tasks:   2 total,   1 running,   1 sleeping,   0 stopped,   0 zombie            
%Cpu(s):  0.0 us,  0.0 sy,  0.0 ni,100.0 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st 
MiB Mem :   9951.4 total,   1242.5 free,   2064.6 used,   6644.2 buff/cache     
MiB Swap:   2048.0 total,   1920.6 free,    127.4 used.   7418.7 avail Mem      
 
  PID USER      PR  NI    VIRT    RES    SHR S  %CPU  %MEM     TIME+ COMMAND    
    1 root      20   0    3752   3020   2544 S   0.0   0.0   0:00.08 bash       
 3063 root      20   0    5740   2652   2264 R   0.0   0.0   0:00.01 top        
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Press q to exit top.

Send interrupt

We can simulate pressing CTRL-C to quit long-running processes:

$ sleep 1000
^C
$

View the corresponding bash.Rmd file to learn more about how this page was generated.