You are not logged in.

#1 2018-04-13 18:42:17

simona70
Banned
Registered: 2017-01-08
Posts: 41

[SOLVED] alias for fast commands

For game I did these alias / commands... as newbbie.

alias get-governor-available='   cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors   '
alias get-governor='    cpupower frequency-info | grep "Il gestore" | awk '\''{ print $3 }'\''  | sed s/\"//g     '

alias get-cpu-sched='   dmesg | grep -i "CPU scheduler"  |  awk '\''{print $6 " " $9 " " $10 " " $11 " " $12}'\''    '
alias get-cpu-sched-avail='   dmesg | grep -i "io scheduler" |  awk '\''{print $8}'\''  | sed ":l; N; s/\n/ /; tl"    '

alias get-io-sched-all-device='    cat /sys/block/sda/queue/scheduler    '
alias get-io-sched='      cat /sys/block/sda/queue/scheduler | cut -d "[" -f2 | cut -d "]" -f1     '
alias get-io-sched-avail='    cat /sys/block/sda/queue/scheduler | sed "s/\[//" | sed "s/\]//"     '

alias get-sync-clock='(timedatectl status  |  grep -q "System clock synchronized: yes") && echo -e "Clock: \e[1;39;41mSync\e[0m" || echo -e "Clock: \e[1;39;41mNot Sync\e[0m"'

I wanted to get cpu governor, cpu scheduler, io scheduler.

Last edited by simona70 (2018-04-15 19:36:44)

Offline

#2 2018-04-13 18:45:59

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,543
Website

Re: [SOLVED] alias for fast commands

Is there a question?

If you want to improve those, I'd *strongly* suggest you trim all the redundancy.  Piping through grep through awk and to sed is ridiculous.  Sed or awk alone could do everything there on their own.

EDIT: and piping from sed to sed is even worse!  Note the following four produce equivalent results.  Only one or two of them are good; one is horrific:

command | sed 's/\[//' | sed 's/\]//'
command | sed 's/\[//;s/\]//'
command | sed 's/[[\]]//g'
command | tr -d '[]'

Oh, and when "command" is just `cat $file` ... that's also pointless:

tr -d '[]' < /sys/block/sda/queue/scheduler

http://porkmail.org/era/unix/award.html

Last edited by Trilby (2018-04-13 18:59:38)


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#3 2018-04-13 18:47:07

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,426
Website

Re: [SOLVED] alias for fast commands

And?  Your question is?


Moving to NC...


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#4 2018-04-14 12:15:51

simona70
Banned
Registered: 2017-01-08
Posts: 41

Re: [SOLVED] alias for fast commands

Thanks for tips.

Offline

Board footer

Powered by FluxBB