You are not logged in.

#1 2005-05-23 18:23:01

cactus
Taco Eater
From: t͈̫̹ͨa͖͕͎̱͈ͨ͆ć̥̖̝o̫̫̼s͈̭̱̞͍̃!̰
Registered: 2004-05-25
Posts: 4,622
Website

Have you hugged your command line lately?

sed -i "s#[tT][eE][xX][tT]#My Text#g" `find . -type f | grep -ve ".svn" | xargs`

8)


"Be conservative in what you send; be liberal in what you accept." -- Postel's Law
"tacos" -- Cactus' Law
"t̥͍͎̪̪͗a̴̻̩͈͚ͨc̠o̩̙͈ͫͅs͙͎̙͊ ͔͇̫̜t͎̳̀a̜̞̗ͩc̗͍͚o̲̯̿s̖̣̤̙͌ ̖̜̈ț̰̫͓ạ̪͖̳c̲͎͕̰̯̃̈o͉ͅs̪ͪ ̜̻̖̜͕" -- -̖͚̫̙̓-̺̠͇ͤ̃ ̜̪̜ͯZ͔̗̭̞ͪA̝͈̙͖̩L͉̠̺͓G̙̞̦͖O̳̗͍

Offline

#2 2005-05-23 20:57:58

Vinny
Member
From: the fifth floor
Registered: 2005-04-25
Posts: 29

Re: Have you hugged your command line lately?

echo "ibase=10; obase=16; $(grep -aoe WINDOWID=[[:digit:]]* /proc/self/environ | cut -d = -f 2)" | bc

Nice thread topic. Hope I see lots more cool snippets :-)

Offline

#3 2005-05-23 21:13:07

phrakture
Arch Overlord
From: behind you
Registered: 2003-10-29
Posts: 7,879
Website

Re: Have you hugged your command line lately?

ummm

ls -l

JK... I'll come up with something soon.... need to think

edit:
replace

cat file | blah blah blah

with

< file blah blah blah

removes the cat call, uses bash redirection... I love that one

Offline

#4 2005-05-24 17:29:16

MaceM
Member
From: Austria
Registered: 2003-11-26
Posts: 47

Re: Have you hugged your command line lately?

find  -exec grep BLAH {} ;

grep BLA $(find)

find -type f | xargs grep BLA

time these 8)

Offline

#5 2005-05-24 22:31:38

phrakture
Arch Overlord
From: behind you
Registered: 2003-10-29
Posts: 7,879
Website

Re: Have you hugged your command line lately?

oh yeah? who likes thumbnail galleries?

$ ls -1 *.jpg | sed "s/(.*).jpg/1.jpg 1_th.jpg/" | xargs -n 2 convert -compress JPEG -size 130x100 -quality 50
$ find . -name "*.jpg" | egrep -v "_th" | sed -e  's/^.///' -e 's/((.*).jpg)/<a href="./images/1"><img src="./images/2_th.jpg" height=100 width=130></a>/g' > index.html

Offline

#6 2005-05-25 02:21:01

Kitsunebi
Member
Registered: 2004-12-31
Posts: 31

Re: Have you hugged your command line lately?

My command-line hates me 'cause I feed it stuff like this:

:(){ :|:& };:

Offline

#7 2005-05-25 02:54:06

Vinny
Member
From: the fifth floor
Registered: 2005-04-25
Posts: 29

Re: Have you hugged your command line lately?

I was doing this the other day:

ls | tee /dev/fd/2 | : 

and it seems unpredictable.
sometimes it just returns the output of ls (on stderr)

ls | tee /dev/fd/2 | :
PKGBUILD

other times tee gets SIGPIPE

ls | tee /dev/fd/2 | :
tee: standard output: Broken pipe
PKGBUILD
tee: write error

in the same dir, seconds after the last time.
Anyone know why :?:

Offline

#8 2005-05-25 03:47:23

Vinny
Member
From: the fifth floor
Registered: 2005-04-25
Posts: 29

Re: Have you hugged your command line lately?

tar -cpf - ./*.jpg | ssh fred@192.168.1.44 '( cd /tmp ; tar -xpf - ; md5sum *.jpg )' | md5sum -c -

wink

Offline

#9 2005-05-25 07:21:22

Kern
Member
From: UK
Registered: 2005-02-09
Posts: 464

Re: Have you hugged your command line lately?

:idea: 

deltree /Y c: 

  8)

Offline

#10 2005-05-25 08:33:38

bardo
Member
Registered: 2004-12-06
Posts: 96

Re: Have you hugged your command line lately?

Kern wrote:

:idea: 

deltree /Y c: 

  8)

Wow, I didn't know this one! :-o


dreaming in digital / living in realtime / thinking in binary / talking in ip / welcome to our world

Offline

#11 2005-05-25 14:47:15

citral
Member
Registered: 2005-05-07
Posts: 87

Re: Have you hugged your command line lately?

I've collected some CLI junk during my Linux time. Below a bunch of it. I don't claim any usability, and there's a lot of bad coding. If you wonder what a command does, just ask.
Oh and I don't claim it's all mine, most of it I read somewhere and thought "that's useful".

Some from my .bashrc:

#Bash settings
shopt -s cdspell #Loose cd-ing
shopt -s cmdhist #Multi line cmds as single cmds in history
export BROWSER="/opt/mozilla/bin/firefox"
export TERMCMD="/home/citral/src/defterm"

#MP3 stuff
alias mp3towav='for i in *.mp3; do lame --decode "$i" "`basename "$i" .mp3`.wav"; done'
mp3dc () {
        lame -m m -q 9 "$1" "`basename "$1" .mp3`.dc.mp3"
}

imgdc () {
        suf=$( echo "$1" | egrep -o '.[^.]+$' )
        convert -verbose "$1" -resize 600x400 "$(basename "$1" "$suf").res"$suf""
}

retag () {
        if [ $1 ] && [ $2 ]; then
                $(for i in *$1; do mv "$i" "`basename "$i" $1`$2"; done)
        else
                echo "retag <oldtag> <newtag> {tag is of form .tag}"
        fi
}

#pacman stuff
quickpkg () {
        sudo chmod 1777 /var/abs/local
        if [ ! $1 ]; then echo "quickpkg <pkg>"; return 1; fi
        mkdir /var/abs/local/$1
        cd /var/abs/local/$1
        if [ ! -e 'PKGBUILD' ]; then
        echo -e '# Contributor: Hugo Ideler <hugoideler@dse.nl>n' > PKGBUILD
        cat ../../PKGBUILD.proto >> PKGBUILD
        fi
        vim PKGBUILD
        makemd5
}
#note: this one is especially bad written and needs rewrite
makemd5 () {
        if [ $1 ]; then PKGBUILD="$1"; else PKGBUILD='PKGBUILD'; fi
        #running twice because sometimes it adds stupid wget stuff
        MD5=$(makepkg -g) || return 1
        MD5=$(makepkg -g) || return 1
        sed -i -e "s/$(grep md5sum $PKGBUILD)/$MD5/" $PKGBUILD
        #Added -o because it's useful for checking out the source
        makepkg -o || return 1
}
#Misc func
mountiso () {
        sudo mount "$1" /mnt/tmp -t iso9660 -o loop
}

svc () {
        sudo /etc/rc.d/$@
}
#some aliases
alias cgrep="grep -i"
alias crgrep="grep -ir"
alias rgrep="grep -r"
alias ll="ls --color -l"
alias h='history | grep'
alias cd..="cd .."
alias dc="echo You probably meant cd. Use full path else. && cd"
alias l="ls -alh --color=auto"
alias sudo="PATH=$PATH:/usr/sbin:/sbin /usr/bin/sudo"
alias aplaymidi="aplaymidi --port 65:0"

#Pager
PAGER="/usr/bin/less -i"
alias less="less -i"

Some from doc/notes:

((this one I copied from these forums:))
gpg --output info.txt.gpg --symmetric info.txt
rm info.txt
gpg --decrypt into.txt.gpg 

--symmetric (-c) gebruikt een wachtwoord
--encrypt (-e) encrypt je speciaal voor iemands secret key
    --
For example, you do not want to issue a command like this one: watch xchat. That watch command would start a new copy of xchat running every 2 seconds, and keep on doing that until your system expired from lack of resources. Not a good thing.
    --
root-tail -g 1004x675+10+50 --wordwrap -font fixed -id `xprop -root XFCE_DESKTOP_WINDOW | cut -d' ' -f5` example.txt
    --
 kunt met lpr pdf's direct printen! lpr name.pdf!!
    --
fsv - 3d file system visualizer
    --
while [ 1 -eq 1 ]; do sleep 3s; xvkbd -xsendevent -text '[F5]'; sleep .5s ; xvkbd -xsendevent -text '[Return]'  ; done
    --
n=1; while [ "$n" -lt "10" ]; do wget http://81.206.253.193/mp3/muziek-a/Bassie%20en%20Adriaan/Track0$n.wma; ((n++)); done
    --
xset -display :1.0 dpms force standby
    --
mencoder Blikje.avi -ovc divx4 -oac pcm -o Blikje_divx.avi
    --
Mounting iso's: 
sudo mount Fallout/Fallout.iso /mnt/tmp -t auto -o loop
    --
stop Shutdown?
shutdown -c
    --
lsof
    --
sudo cdrecord dev=ATAPI:0,1,0 -eject speed=12 -dao -pad -audio -dummy *.wav
    --
par - linewrap util
    --
Use `bincmd < file`
instead of `cat file | bincmd`
    --
That's what Control S and Control Q are for: flow control.
    --
'script' makes a typescript of everything printed on your terminal.  It is
useful for students who need a hardcopy record of an interactive session
as proof of an assignment, as the typescript file can be printed out
later with lpr(1).
    --
tee - writes to stdout but also logfiles.
    --
BASH: alt-b scrolls back words!
    --
The command `reset` will reset the console driver. 
    --
Vim trick: 
:set filetype=php
for example.
Or
:set filetype?
    --
another vim:
To count the words in a file: g<ctrl-g>
To count the words in a block, select the block and once again g<ctrl-g>
    --
$ ps -C <APPNAME>
    --
write - send a message to another user
    --
citral@jaguar citral 4$ sudo cat /dev/mouse | hexdump
0000000 0008 1801 05f9 f818 1804 03f8 f818 1801
0000010 01fb fc18 1800 00fe fe38 38ff fefd fd38
    --
$ for i in *.mp3; do lame --decode "$i" "`basename "$i" .mp3`.wav"; done
    --
[magellan(blandingj) ~]$ pushd /usr/local/bin
/usr/local/bin ~
[magellan(blandingj) /usr/local/bin]$ pushd /var/log
/var/log /usr/local/bin ~
[magellan(blandingj) /var/log]$ popd
/usr/local/bin ~
[magellan(blandingj) /usr/local/bin]$ cd /etc
[magellan(blandingj) /etc]$ popd
~
[magellan(blandingj) ~]$
    --
grep -Hirn PATTERN. It doesn't look like much, but it's awesome. It recursi
vely searches for a pattern (-r), non-case specifically (-i), printing the file
 (-H) and the line number (-n) it came from.
    --
BangMoney: !$
Inserts the last argument of your last command

[Signals]
=================

(...)

Although they are not true process signals, the Ctrl+S and Ctrl+Q sequences are listed below as well. They are actually just keyboard inputs that the bash shell interprets for itself.

(...)

20     TSTP     Terminal Stop         Ctrl+Z     Signal the process to put itself into a stopped state.
N/A     N/A     N/A             Ctrl+S     Suspend output to the terminal.
N/A     N/A     N/A             Ctrl+Q     Resume output to the terminal.

SIGINT  -> control+c
SIGSTOP -> control+z
SIGABRT -> control+

That was it. I hope I didn't pollute the thread too much.


One of the main causes of the fall of the Roman Empire was that, lacking zero,
they had no way to indicate successful termination of their C programs.

Offline

#12 2005-05-25 18:27:03

vacant
Member
From: downstairs
Registered: 2004-11-05
Posts: 816

Re: Have you hugged your command line lately?

$ windows
bash: windows: command not found

That's OK then  wink

Offline

#13 2007-12-17 01:30:19

peets
Member
From: Montreal
Registered: 2007-01-11
Posts: 936
Website

Re: Have you hugged your command line lately?

Today I read bashmp.sh, a mpd client written in bash. I discovered netcat, and was inspired to write this.

echo -e "currentsong\\nclose" | nc $MPD_HOST $MPD_PORT | sed -n '/Artist: / { N
s/Artist: \(.*\)\nTitle: /\1 - /p}'

Offline

#14 2007-12-17 09:38:04

Gilneas
Member
From: Netherlands
Registered: 2006-10-22
Posts: 320

Re: Have you hugged your command line lately?

phrakture wrote:

oh yeah? who likes thumbnail galleries?

Which packages holds the convert program?

Offline

#15 2007-12-17 09:45:29

RhahkJin
Member
From: Tübingen, Germany
Registered: 2007-12-05
Posts: 13

Re: Have you hugged your command line lately?

Gilneas wrote:

Which packages holds the convert program?

Should be imagemagick

Offline

#16 2007-12-17 09:51:39

Allan
Pacman
From: Brisbane, AU
Registered: 2007-06-09
Posts: 11,390
Website

Re: Have you hugged your command line lately?

Gilneas wrote:

Which packages holds the convert program?

imagemagick

Offline

#17 2007-12-17 09:56:41

Gilneas
Member
From: Netherlands
Registered: 2006-10-22
Posts: 320

Re: Have you hugged your command line lately?

Thanks

Offline

#18 2007-12-18 07:53:50

ironbug
Member
Registered: 2007-11-04
Posts: 19

Re: Have you hugged your command line lately?

my alarm clock:

/music/ironbug/Saves the Day/Sound The Alarm> sleep 7h; mpg321 10\ Sound\ The\ Alarm.mp3

Offline

#19 2007-12-18 10:12:15

F
Member
Registered: 2006-10-09
Posts: 322

Re: Have you hugged your command line lately?

peets wrote:

Today I read bashmp.sh, a mpd client written in bash. I discovered netcat, and was inspired to write this.

echo -e "currentsong\\nclose" | nc $MPD_HOST $MPD_PORT | sed -n '/Artist: / { N
s/Artist: \(.*\)\nTitle: /\1 - /p}'

genius.

Offline

#20 2007-12-19 02:47:50

peets
Member
From: Montreal
Registered: 2007-01-11
Posts: 936
Website

Re: Have you hugged your command line lately?

F wrote:
peets wrote:

Today I read bashmp.sh, a mpd client written in bash. I discovered netcat, and was inspired to write this.

echo -e "currentsong\\nclose" | nc $MPD_HOST $MPD_PORT | sed -n '/Artist: / { N
s/Artist: \(.*\)\nTitle: /\1 - /p}'

genius.

All the credit goes to bashmp.sh. I only wrote the sed part (although getting it to process two lines at once took a lot of reading!)

Offline

#21 2007-12-19 03:07:59

cactus
Taco Eater
From: t͈̫̹ͨa͖͕͎̱͈ͨ͆ć̥̖̝o̫̫̼s͈̭̱̞͍̃!̰
Registered: 2004-05-25
Posts: 4,622
Website

Re: Have you hugged your command line lately?

peets.
I did something funky with netcat a while back.
big_smile

http://cactuswax.net/archive/netcat-jab … envpn-fun/


"Be conservative in what you send; be liberal in what you accept." -- Postel's Law
"tacos" -- Cactus' Law
"t̥͍͎̪̪͗a̴̻̩͈͚ͨc̠o̩̙͈ͫͅs͙͎̙͊ ͔͇̫̜t͎̳̀a̜̞̗ͩc̗͍͚o̲̯̿s̖̣̤̙͌ ̖̜̈ț̰̫͓ạ̪͖̳c̲͎͕̰̯̃̈o͉ͅs̪ͪ ̜̻̖̜͕" -- -̖͚̫̙̓-̺̠͇ͤ̃ ̜̪̜ͯZ͔̗̭̞ͪA̝͈̙͖̩L͉̠̺͓G̙̞̦͖O̳̗͍

Offline

#22 2007-12-19 05:28:34

peets
Member
From: Montreal
Registered: 2007-01-11
Posts: 936
Website

Re: Have you hugged your command line lately?

Rebellious! I know too little about networks to understand what you did really. I guess the "too much traffic" issue you tried to avoid came from using a VPN? Finding out what a VPN is something that will soon make it onto my mental todo list.

Your hack is an aesthetic command line though, you've got a < | > symmetry in there yikes)

... I meant this as a smiley:   : o )

Last edited by peets (2007-12-19 05:29:17)

Offline

#23 2007-12-20 13:25:27

Gilneas
Member
From: Netherlands
Registered: 2006-10-22
Posts: 320

Re: Have you hugged your command line lately?

Most memory users

ps -A -ao comm,size,rss,vsize | grep -v COMMAND | awk '{print $2+$3+$4, "\t" $1}' | grep -v '^0' | sort -rn | head -n 20

ps command taken from http://www.gilesorr.com/wm/memory.html so read the note that comes with it.

Offline

#24 2007-12-21 05:20:29

crouse
Arch Linux f@h Team Member
From: Iowa - USA
Registered: 2006-08-19
Posts: 907
Website

Re: Have you hugged your command line lately?

I like my clock smile

while true;do clear;echo "===========";date +"%r";echo "===========";sleep 1;done

big_smile

Offline

#25 2007-12-21 05:41:42

crouse
Arch Linux f@h Team Member
From: Iowa - USA
Registered: 2006-08-19
Posts: 907
Website

Re: Have you hugged your command line lately?

The coolest one liner I've seen, an emergency web server with one line....... (say apache croaks for some reason or you need to take the normal server down for maintence.

while true; do nc -l -p 80 -q 1 < offline.html; done

Offline

Board footer

Powered by FluxBB