LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   LQ Poll: What's your favorite Linux terminal trick? (https://www.linuxquestions.org/questions/linux-general-1/lq-poll-what%27s-your-favorite-linux-terminal-trick-4175654014/)

jeremy 05-16-2019 08:28 AM

LQ Poll: What's your favorite Linux terminal trick?
 
The official LQ poll series continues. This time we want to know: What's your favorite Linux terminal trick?

--jeremy

greencedar 05-16-2019 08:35 AM

I enjoy:

Code:

~$ sl

bigearsbilly 05-16-2019 09:55 AM

Code:

alias path='(IFS=:;ls -1d $PATH |  nl)'


0:% path
ls: cannot access '/home/billy/R/usr/bin': No such file or directory
ls: cannot access '/home/billy/R/bin': No such file or directory
    1  /bin
    2  /home/billy/bin
    3  /home/billy/go
    4  /home/billy/usr/bin
    5  /sbin
    6  /usr/bin
    7  /usr/games
    8  /usr/local/bin
    9  /usr/local/games
    10  /usr/sbin


thethinker 05-16-2019 09:58 AM

Quote:

Originally Posted by greencedar (Post 5995646)
I enjoy:

Code:

~$ sl

Didn't know what you are talking about - not installed by default on my system (Xubuntu something something). Does that count as a "trick"? Because if anything you can install counts as a trick...

On the other hand, now that I've installed it's my new favorite thing :-)

I am constantly combining pdfs via terminal:

Code:

~$ gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=<blah> <infile1> <infile2> ...
but also doubt that's a trick. I mean, is tab-complete a trick? If so, that's my favorite because I could not live without it.

tshikose 05-16-2019 10:18 AM

I cannot live without the below in my ~root/.bash_profile
Code:

export HISTTIMEFORMAT='%F %T  '
export HISTSIZE=1000000
export HISTCONTROL=ignoreboth


Jack_Fedora 05-16-2019 10:33 AM

Adding Line Numbers
 
Setting up Vim so that line numbers are added when coding, and line numbers are added when printing a hard copy. This is performed as a routine so the number show up anytime a new file is created or an existing file is opened.:)

miquelets46 05-16-2019 10:47 AM

Not using it at all! A+Pete

jsbjsb001 05-16-2019 11:09 AM

piping and redirection.

hydrurga 05-16-2019 11:23 AM

I know it's very simple, but it took me a while to realise that I could copy and paste text to/from my terminal by using shift-ctrl-c and shift-ctrl-v.

wjaguar 05-16-2019 11:58 AM

In ~/.bash_profile:
Code:

PROMPT_COMMAND="$PROMPT_COMMAND${PROMPT_COMMAND:+;} history -a; history -r"
Keeping consistent history when running several shells at once.

And, naturally, in ~/.bashrc:
Code:

source ~/.bash_profile
Having shells init the same regardless of the way they are started.

fatmac 05-16-2019 12:16 PM

Just knowing how to use the command line is about as 'trick' as I get. ;)

But, yeah, piping & redirection gets used quite often, & shell scripting small jobs.

DGPickett 05-16-2019 12:17 PM

Inline named pipes <(...), >(...) !

Turbocapitalist 05-16-2019 12:39 PM

I'd say for bash and zsh it would be command substitution $(...) and process substitution < <(...) I use the former a lot but have only occasional opportunity to use the latter.

Edit: here's probably my most unusual use of command substitution. It's from an OpenBSD system which would report the battery status in the shell prompt, but only while the machine was unplugged:

Code:

export PS1="\$(if [ 1 -ne \$(/usr/sbin/apm -a) ]; then
  echo \"\$(/usr/sbin/apm -l)% \W \\$ \";

elif [ 3 -eq \$(/usr/sbin/apm -b) ]; then
  echo \"+\$(/usr/sbin/apm -l)% \W \\$ \";

else
  echo '\W \\$ '

fi)"


RickDeckard 05-16-2019 12:52 PM

I don't know if this counts, but I have cases where I need to use a lot of [[ ]] shell scripting in cron and I'll be timing resource intensive automated scans to run in absence of a particular PID or file which implies another resource heavy tool - so as not to overburden the servers. The "flock" command has been my friend for sure.

rokytnji 05-16-2019 01:23 PM

Have to install it https://www.linuxquestions.org/quest...ed-4175625577/


Code:

pinxi -v8
trips my trigger when trying to get system info from a new user.


All times are GMT -5. The time now is 05:07 PM.