Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Console / shell tips & tricks
View unanswered posts
View posts from last 24 hours

Goto page Previous  1, 2, 3 ... 12, 13, 14, 15, 16  Next  
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
/dev/random
l33t
l33t


Joined: 26 Nov 2004
Posts: 704
Location: Austin, Texas, USA

PostPosted: Sun Dec 09, 2007 11:00 pm    Post subject: Re: Share you totally awesome shell tips Reply with quote

PraetorZero wrote:
melange wrote:
Do as the topic says, share your tips and great ideas :)

It could be anything from an awesome script like unfoo, to something really useful shell utils like CTRL+C, bg, fg and jobs, or absolutely useless like "/usr/bin/yes" or "/usr/games/banner"


What does yes do? Just do a Y and carriage return?

It prints a string repeatedly until you kill it with ^C.

# yes foo
Would print foo to the screen until you kill it.
Back to top
View user's profile Send private message
mdeininger
Veteran
Veteran


Joined: 15 Jun 2005
Posts: 1740
Location: Emerald Isles, observing Dublin's docklands

PostPosted: Sun Dec 09, 2007 11:00 pm    Post subject: Re: Share you totally awesome shell tips Reply with quote

PraetorZero wrote:
melange wrote:
Do as the topic says, share your tips and great ideas :)

It could be anything from an awesome script like unfoo, to something really useful shell utils like CTRL+C, bg, fg and jobs, or absolutely useless like "/usr/bin/yes" or "/usr/games/banner"


What does yes do? Just do a Y and carriage return?

y
y
y
y
y
y
y
y
y
y
y
y
y
y
y
y
y
^C
_________________
"Confident, lazy, cocky, dead." -- Felix Jongleur, Otherland

( Twitter | Blog | GitHub )
Back to top
View user's profile Send private message
melange
Tux's lil' helper
Tux's lil' helper


Joined: 16 Sep 2004
Posts: 110

PostPosted: Sun Dec 09, 2007 11:02 pm    Post subject: Re: Share you totally awesome shell tips Reply with quote

PraetorZero wrote:
melange wrote:
Do as the topic says, share your tips and great ideas :)

It could be anything from an awesome script like unfoo, to something really useful shell utils like CTRL+C, bg, fg and jobs, or absolutely useless like "/usr/bin/yes" or "/usr/games/banner"


What does yes do? Just do a Y and carriage return?


actually it's not *totally* useless :) assume you have an app which asks a lot of y/N questions and you just want to say yes to all of them. Then you just do:

Code:

$ yes | my_app
Back to top
View user's profile Send private message
arcanex
n00b
n00b


Joined: 10 Jun 2007
Posts: 1

PostPosted: Sun Dec 09, 2007 11:39 pm    Post subject: Reply with quote

Code:

alias q='exit'


Convenient if you open and close the terminal a lot. Then, if you want to launch an X app without keeping the terminal open, you can just append '&q' to the end of the command.

Code:

set -o vi


Turns on vi mode in bash. Pretty much required if you like vi. Especially useful is the '/' command to search your command history.

If you like vi, you might like this script I use as my XClipboard manager (requires xclip):

Code:

#!/bin/sh

VI="vim -n"
XCLIP=/home/paulo/bin/xclip
TMPFILE=/tmp/viclip.${RANDOM}.tmp

${XCLIP} -o > ${TMPFILE}

until [ "$I" == "q" ]
do
   ${VI} ${TMPFILE}
   ${XCLIP} < ${TMPFILE}
   clear
   ${XCLIP} -o
   echo ""
   echo "===[Type 'q' to quit, 'p' to re-paste, any other key to re-edit]==="
   read I
   while [ "$I" == "p" ]
   do
      ${XCLIP} < ${TMPFILE}
      echo "==[repasted]=="   
      read I
   done
done

rm ${TMPFILE}


Then I bind a key to launch this script (viclip.sh). It opens up vi with the current XClipboard content, allows you to edit it, then keeps the xterm open so that you don't lose it (which is really easy), and also allows you to re-paste (to the XClipboard) or re-edit. I also like to use it as an all-purpose temporary text file editor; I wrote this post in 'viclip.sh', for example, then pasted it to the Firefox text box.

Also, instead of Ctrl-s and Ctrl-q, I prefer Ctrl-z. It halts the program execution entirely, and that's usually what I want to do (when compiling, for example.) Then I can just 'fg' back if and when I want to.
Back to top
View user's profile Send private message
papal_authority
Veteran
Veteran


Joined: 31 Mar 2004
Posts: 1823
Location: Canada

PostPosted: Sun Dec 09, 2007 11:57 pm    Post subject: Reply with quote

mdeininger wrote:
it's a terminal function... works on "real" virtual terminals on tty1 and the like, and on virtual terminals like xterm... at least those're the only ones i tried it on.

Yah, it's software flow control (i.e. XON/XOFF), I generally only use it when I'm on an actual hardwired terminal. Once you have a mouse, multiple sessions, and cut n' paste, it really isn't all that useful IMHO. To each their own though :)
_________________
The free market gave me gonorrhea.
Back to top
View user's profile Send private message
mdeininger
Veteran
Veteran


Joined: 15 Jun 2005
Posts: 1740
Location: Emerald Isles, observing Dublin's docklands

PostPosted: Mon Dec 10, 2007 12:04 am    Post subject: Reply with quote

papal_authority wrote:
mdeininger wrote:
it's a terminal function... works on "real" virtual terminals on tty1 and the like, and on virtual terminals like xterm... at least those're the only ones i tried it on.

Yah, it's software flow control (i.e. XON/XOFF), I generally only use it when I'm on an actual hardwired terminal. Once you have a mouse, multiple sessions, and cut n' paste, it really isn't all that useful IMHO. To each their own though :)
kinda depends... when you're compiling something big or you're debugging something with a lot of logfile output, and your terminal's scrollback buffer is a bit short, ctrl+s is pretty handy :).

it's handy to know either way; it also seems to be one of those lesser-known bits, and it's somewhat console-related, so i figured i'd throw it in =)
_________________
"Confident, lazy, cocky, dead." -- Felix Jongleur, Otherland

( Twitter | Blog | GitHub )
Back to top
View user's profile Send private message
poly_poly-man
Advocate
Advocate


Joined: 06 Dec 2006
Posts: 2477
Location: RIT, NY, US

PostPosted: Mon Dec 10, 2007 12:51 am    Post subject: Reply with quote

^d is your friend ;)

Also, shift Page up/down is good, and (ctrl-)alt-Fx

also, the best command ever:

telnet polypmanports.hopto.org

poly-p man
_________________
iVBORw0KGgoAAAANSUhEUgAAA

avatar: new version of logo - see topic 838248. Potentially still a WiP.
Back to top
View user's profile Send private message
denstark
l33t
l33t


Joined: 02 Jun 2003
Posts: 654
Location: sd.ca.us

PostPosted: Mon Dec 10, 2007 1:06 am    Post subject: Reply with quote

poly_poly-man wrote:
^d is your friend ;)

Also, shift Page up/down is good, and (ctrl-)alt-Fx

also, the best command ever:

telnet polypmanports.hopto.org

poly-p man


that wasn't a plug at ALL.
_________________
Blog
Code:
denstark> starbuck authorizes torture?
rokstar> sure they do, you tried their coffee?
Back to top
View user's profile Send private message
poly_poly-man
Advocate
Advocate


Joined: 06 Dec 2006
Posts: 2477
Location: RIT, NY, US

PostPosted: Mon Dec 10, 2007 1:10 am    Post subject: Reply with quote

denstark wrote:
poly_poly-man wrote:
^d is your friend ;)

Also, shift Page up/down is good, and (ctrl-)alt-Fx

also, the best command ever:

telnet polypmanports.hopto.org

poly-p man


that wasn't a plug at ALL.


Just a simple command that works on many systems :D

poly-p man
_________________
iVBORw0KGgoAAAANSUhEUgAAA

avatar: new version of logo - see topic 838248. Potentially still a WiP.
Back to top
View user's profile Send private message
Bones McCracker
Veteran
Veteran


Joined: 14 Mar 2006
Posts: 1611
Location: U.S.A.

PostPosted: Mon Dec 10, 2007 1:10 am    Post subject: Reply with quote

Repeat the last command, replacing string1 with string2
Code:
^string1^string2^

By the way, there's a thread in the Tips & Tricks forum on the exact same topic that has accumulated five years worth of tips:
https://forums.gentoo.org/viewtopic-t-15443-highlight-shell.html
_________________
patrix_neo wrote:
The human thought: I cannot win.
The ratbrain in me : I can only go forward and that's it.


Last edited by Bones McCracker on Mon Dec 10, 2007 1:45 am; edited 2 times in total
Back to top
View user's profile Send private message
Etal
Veteran
Veteran


Joined: 15 Jul 2005
Posts: 1931

PostPosted: Mon Dec 10, 2007 1:16 am    Post subject: Reply with quote

mdeininger wrote:
papal_authority wrote:
mdeininger wrote:
it's a terminal function... works on "real" virtual terminals on tty1 and the like, and on virtual terminals like xterm... at least those're the only ones i tried it on.

Yah, it's software flow control (i.e. XON/XOFF), I generally only use it when I'm on an actual hardwired terminal. Once you have a mouse, multiple sessions, and cut n' paste, it really isn't all that useful IMHO. To each their own though :)
kinda depends... when you're compiling something big or you're debugging something with a lot of logfile output, and your terminal's scrollback buffer is a bit short, ctrl+s is pretty handy :).

it's handy to know either way; it also seems to be one of those lesser-known bits, and it's somewhat console-related, so i figured i'd throw it in =)

I prefer ScrollLock
_________________
“And even in authoritarian countries, information networks are helping people discover new facts and making governments more accountable.”– Hillary Clinton, Jan. 21, 2010
Back to top
View user's profile Send private message
Bones McCracker
Veteran
Veteran


Joined: 14 Mar 2006
Posts: 1611
Location: U.S.A.

PostPosted: Mon Dec 10, 2007 2:09 am    Post subject: Reply with quote

More of a console tip than a shell tip:

Command history incremental search (as a key combo).

1. Type first few chars of some command in your history you'd like to repeat
2. press 'Meta+PgUp'

This retrieves the most recent matching command (right one? hit return to execute; not right? press it again and incremental search continues).

The modifier key varies depending on how your /etc/inputrc is set up and what you are using (tty, gnome-terminal, konsole, etc.)

I have found this to be very handy. You'll be surprised how much of your terminal work is the same commands used over and over. There are other related key combinations (explore inputrc and man bash), but that's the one I've found the most useful.
_________________
patrix_neo wrote:
The human thought: I cannot win.
The ratbrain in me : I can only go forward and that's it.
Back to top
View user's profile Send private message
bunder
Bodhisattva
Bodhisattva


Joined: 10 Apr 2004
Posts: 5933

PostPosted: Mon Dec 10, 2007 4:12 am    Post subject: Reply with quote

BoneKracker wrote:
By the way, there's a thread in the Tips & Tricks forum on the exact same topic that has accumulated five years worth of tips:
https://forums.gentoo.org/viewtopic-t-15443-highlight-shell.html


merged. :wink:
_________________
Neddyseagoon wrote:
The problem with leaving is that you can only do it once and it reduces your influence.

banned from #gentoo since sept 2017
Back to top
View user's profile Send private message
bunder
Bodhisattva
Bodhisattva


Joined: 10 Apr 2004
Posts: 5933

PostPosted: Mon Dec 10, 2007 4:14 am    Post subject: Reply with quote

want to look for bots who tried logging into your ssh/ftp servers in the past day?

Code:
grep "`date +'%b %e'`" /var/log/auth.log | grep "Invalid user"
grep "`date +'%b %e'`" /var/log/vsftpd.log | grep "FAIL LOGIN"


works great in cron. :wink:
_________________
Neddyseagoon wrote:
The problem with leaving is that you can only do it once and it reduces your influence.

banned from #gentoo since sept 2017
Back to top
View user's profile Send private message
JeliJami
Veteran
Veteran


Joined: 17 Jan 2006
Posts: 1086
Location: Belgium

PostPosted: Mon Dec 10, 2007 3:07 pm    Post subject: Reply with quote

BoneKracker wrote:
More of a console tip than a shell tip:

Command history incremental search (as a key combo).

1. Type first few chars of some command in your history you'd like to repeat
2. press 'Meta+PgUp'

This retrieves the most recent matching command (right one? hit return to execute; not right? press it again and incremental search continues).


Cool, but I like Ctl-R better
1. Type Ctl-R (prompt changes)
2. Type some chars of a former command (does not need to be the first ones)
3. Use backspace to correct errors
_________________
Unanswered Post Initiative | Search | FAQ
Former username: davjel
Back to top
View user's profile Send private message
Bones McCracker
Veteran
Veteran


Joined: 14 Mar 2006
Posts: 1611
Location: U.S.A.

PostPosted: Mon Dec 10, 2007 5:23 pm    Post subject: Reply with quote

davjel wrote:
BoneKracker wrote:
More of a console tip than a shell tip:

Command history incremental search (as a key combo).

1. Type first few chars of some command in your history you'd like to repeat
2. press 'Meta+PgUp'

This retrieves the most recent matching command (right one? hit return to execute; not right? press it again and incremental search continues).


Cool, but I like Ctl-R better
1. Type Ctl-R (prompt changes)
2. Type some chars of a former command (does not need to be the first ones)
3. Use backspace to correct errors


Cool. I didn't know about that. I like that better too! :D
_________________
patrix_neo wrote:
The human thought: I cannot win.
The ratbrain in me : I can only go forward and that's it.
Back to top
View user's profile Send private message
swimmer
Veteran
Veteran


Joined: 15 Jul 2002
Posts: 1330
Location: Netherlands

PostPosted: Mon Dec 10, 2007 10:44 pm    Post subject: Reply with quote

Hmm - is this shell-dependent? If I use Ctrl-R in zsh nothing happens ...

Greetz
swimmer
Back to top
View user's profile Send private message
JeliJami
Veteran
Veteran


Joined: 17 Jan 2006
Posts: 1086
Location: Belgium

PostPosted: Tue Dec 11, 2007 8:29 am    Post subject: Reply with quote

swimmer wrote:
Hmm - is this shell-dependent? If I use Ctrl-R in zsh nothing happens ...


/me using bash
_________________
Unanswered Post Initiative | Search | FAQ
Former username: davjel
Back to top
View user's profile Send private message
Bones McCracker
Veteran
Veteran


Joined: 14 Mar 2006
Posts: 1611
Location: U.S.A.

PostPosted: Tue Dec 11, 2007 7:04 pm    Post subject: Reply with quote

zsh must have command history incremental search -- it's probably a different key binding or something. Look at info zsh or something. On bash these sorts of things are set up in inputrc.
_________________
patrix_neo wrote:
The human thought: I cannot win.
The ratbrain in me : I can only go forward and that's it.
Back to top
View user's profile Send private message
swimmer
Veteran
Veteran


Joined: 15 Jul 2002
Posts: 1330
Location: Netherlands

PostPosted: Tue Dec 11, 2007 11:00 pm    Post subject: Reply with quote

Hmm - 'pinfo zsh' mentions indeed Ctrl-R for incremental history search backwards but using this keybinding nothing happens whereas it works as designed in bash :-/

But hey - I started using zsh recently and am still an absolut n00b in his usage ;-)

Thanks anyway
swimmer
Back to top
View user's profile Send private message
Bones McCracker
Veteran
Veteran


Joined: 14 Mar 2006
Posts: 1611
Location: U.S.A.

PostPosted: Tue Dec 11, 2007 11:51 pm    Post subject: Reply with quote

I really hate to say it, but .... you could always, uh ... RTFM. :P
_________________
patrix_neo wrote:
The human thought: I cannot win.
The ratbrain in me : I can only go forward and that's it.
Back to top
View user's profile Send private message
Ox-
Guru
Guru


Joined: 19 Jun 2003
Posts: 305

PostPosted: Wed Dec 12, 2007 4:47 pm    Post subject: Reply with quote

swimmer wrote:
Hmm - 'pinfo zsh' mentions indeed Ctrl-R for incremental history search backwards but using this keybinding nothing happens whereas it works as designed in bash :-/

But hey - I started using zsh recently and am still an absolut n00b in his usage ;-)

Thanks anyway
swimmer
Going off the top of my head here so I could be wrong, but ctrl-R for history search is usually the key binding in "emacs mode". If you shell editing mode is something else like vi then binding will be different. It's been 16-years since I last used zsh and it's not installed on my box so I can't look up the stuff in zsh.1 for you :)
Back to top
View user's profile Send private message
ppurka
Advocate
Advocate


Joined: 26 Dec 2004
Posts: 3256

PostPosted: Thu Dec 13, 2007 12:30 am    Post subject: Reply with quote

duh!
Code:
echo "bindkey \"^R\"                history-incremental-search-backward
bindkey \"^S\"                history-incremental-search-forward" >> .zshrc
. .zshrc

_________________
emerge --quiet redefined | E17 vids: I, II | Now using kde5 | e is unstable :-/
Back to top
View user's profile Send private message
Bones McCracker
Veteran
Veteran


Joined: 14 Mar 2006
Posts: 1611
Location: U.S.A.

PostPosted: Thu Dec 13, 2007 1:07 am    Post subject: Reply with quote

ppurka wrote:
duh!


http://www.amazon.com/How-Win-Friends-Influence-People/dp/0671723650
_________________
patrix_neo wrote:
The human thought: I cannot win.
The ratbrain in me : I can only go forward and that's it.
Back to top
View user's profile Send private message
ppurka
Advocate
Advocate


Joined: 26 Dec 2004
Posts: 3256

PostPosted: Thu Dec 13, 2007 3:31 am    Post subject: Reply with quote

BoneKracker wrote:
ppurka wrote:
duh!


http://www.amazon.com/How-Win-Friends-Influence-People/dp/0671723650
eww! Who reads all that :roll:
_________________
emerge --quiet redefined | E17 vids: I, II | Now using kde5 | e is unstable :-/
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Goto page Previous  1, 2, 3 ... 12, 13, 14, 15, 16  Next
Page 13 of 16

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum