RJ
Flight Engineer Flight Engineer
Flight Engineer
  • 2,363 Views

Re: What's your favorite tool/cmd in Linux?

Agree with you James, I constantly push the results of one command to another, and sometimes to inline perl commands.  

I'll harvest out the items from some list, and then build an array and pipe it as such:

[some command harvesting out in items in bash] | perl -ne 'print;chomp;system("bash commands go here")'

 (see script I made at https://access.redhat.com/discussions/3487481 for more)

Another thing I've found recently is to build "shortcut conditional commands", such as this bit which sets a value using && for pass or || for conditional 'fail':

[ -d /sys/firmware/efi ] && fw="UEFI" || fw="BIOS"
echo -e "$fw"
if [ "$fw" == "UEFI" ] ; then
echo -e "\n\tUEFI detected, this is a ($fw) system.\n\setting \$fw variable to ($fw)..."
mygrub='/boot/efi/EFI/redhat/grub.cfg'
else
echo -e "\n\t($fw) system detected, proceeding...\n"
mygrub='/boot/grub2/grub.cfg'
fi
 

There's some other sed methods I hadn't seen that I borrowed from Ryan Sawhill such as:

rpm -q prelink >/dev/null && sed -i '/^PRELINKING/s,yes,no,' /etc/sysconfig/prelink
 This will onlly flip the value of "PRELINKING' from yes to no if the rpm prelink exists.  The use of sed here is a bit lesser known.  (hat tip Red Hatter Ryan Sawhill for that one)

RJ
Reply
Loading...
jessesar
Cadet
Cadet
  • 2,519 Views

Re: What's your favorite tool/cmd in Linux?

 @JamesM I couldn't agree more, I use for loops and and pipes to put together various one-liners hourly.

Reply
Loading...
heatmiser
Flight Engineer Flight Engineer
Flight Engineer
  • 2,501 Views

Re: What's your favorite tool/cmd in Linux?

0 Kudos
Reply
Loading...
shauny
Mission Specialist
Mission Specialist
  • 2,489 Views

Re: What's your favorite tool/cmd in Linux?

@jessesar you beat me to it. I was going to say the ability to do for loops straight from the command line has been absolutely invaluable. 

I guess our answer is less a command and more tool, bash. 

Reply
Loading...
Martin
Flight Engineer Flight Engineer
Flight Engineer
  • 2,403 Views

Re: What's your favorite tool/cmd in Linux?

Personally i use egrep a lot when search for multiple pattern in a source. lsof and ps are also tools i use every day

0 Kudos
Reply
Loading...
rdekens
Mission Specialist
Mission Specialist
  • 2,372 Views

Re: What's your favorite tool/cmd in Linux?

maybe very old school but still works

init 0

it's like signal to the end of my day.

0 Kudos
Reply
Loading...
Robvd46
Flight Engineer Flight Engineer
Flight Engineer
  • 2,369 Views

Re: What's your favorite tool/cmd in Linux?

My favorite would be Ctrl+R to do a "reverse-i-search"

Type a letter - like s - and you'll get a match for the most recent command in your history starting with s

Very usefull when I am busy troubleshooting.

0 Kudos
Reply
Loading...
Lisenet
Starfighter Starfighter
Starfighter
  • 2,364 Views

Re: What's your favorite tool/cmd in Linux?

The pipe character as per @JamesM comment, Ctrl+R to do a reverse-i-search as @Robvd46 said, and Crtl+. (note the dot at the end) to use the last word of the previous command.

0 Kudos
Reply
Loading...
itnet7
Mission Specialist
Mission Specialist
  • 2,233 Views

Re: What's your favorite tool/cmd in Linux?

Command recall is by far one of my favorite things to do daily! +1

0 Kudos
Reply
Loading...
George-Hacker
Flight Engineer Flight Engineer
Flight Engineer
  • 2,361 Views

Re: What's your favorite tool/cmd in Linux?

Lightweight tool = cut

Heavyweight tool = awk

When used in pipes these two tools can extract the data that I need from the output of another command. awk is a full-blown C-like interpreter.

Reply
Loading...
Join the discussion
You must log in to join this conversation.