
-----------------------------------
btiffin
Sat Jan 10, 2009 11:17 am

Share your tips, wisdom and finds
-----------------------------------
A couple GNU/Linux shell tricks

Want to know what date next Friday is?$ date -d 'next friday'
Fri Jan 16 00:00:00 EST 2009

Want to know what commands you most often use?$ history|awk '{print $2}'|awk 'BEGIN {FS="|"} {print $1}'|sort|uniq -c|sort -rn|head -10
    153 cd
     48 vi
     39 list
     29 man
     19 rebview
     16 cobc
     15 scp
     15 cp
     12 ls
     11 make

And so you know; my list command is an alias for view (vi readonly mode), but I got used to a list program back in the DOS days and moved the alias to my Coherent system.  Now I'm programmed to type list instead of more, less or view and I alias it everywhere. The programmed response grows more ingrained every year.  And what did I learn from that top 10?  I should either reorganize my directory structure and where I put files or perhaps work on less simultaneous projects with all the associated back and forth.  ;)

I'd be interested to see other favourite tips and tidbits.  By the way; IBM's developerworks and publib is an awesome resource; 
http://www-128.ibm.com/developerworks/aix/library/au-productivitytips.html?ca=dgr-lnxw07UNIX-Office-Tips

Cheers

-----------------------------------
Tony
Sat Jan 10, 2009 3:40 pm

RE:Share your tips, wisdom and finds
-----------------------------------
my best trick...

tony$ irb
>> 

;)

-----------------------------------
Unforgiven
Sat Jan 10, 2009 6:17 pm

RE:Share your tips, wisdom and finds
-----------------------------------
Great thread idea.

Not sure if this is such a "shell trick" but if you use the command line at all, and don't already know about `screen`... find out about it. It's wonderful.

-----------------------------------
OneOffDriveByPoster
Sat Jan 10, 2009 8:49 pm

Re: Share your tips, wisdom and finds
-----------------------------------

    153 cd
I should either reorganize my directory structure and where I put files or perhaps work on less simultaneous projects with all the associated back and forth.  ;)Or you could use screen or invest in using X for multiple windows.  VNC is great.  You can also use "pushd" and "popd".

-----------------------------------
btiffin
Sat Jan 10, 2009 9:51 pm

Re: Share your tips, wisdom and finds
-----------------------------------

    153 cd
I should either reorganize my directory structure and where I put files or perhaps work on less simultaneous projects with all the associated back and forth.  ;)Or you could use screen or invest in using X for multiple windows.  VNC is great.  You can also use "pushd" and "popd".
I use Konsole; 6 shell windows; one REBOL and one Root Shell waiting for a password running all the time.
When I need to transpose information from site to textfile I open a terminal window in Konqueror to fire up vi.

I just happen to have learned bad habits with jumping to build; cd ../dir ; back to build ; cd ../../someother ; back to build ; rinse and repeat;  (using history and cursor keys) when I develop.  This is usually occurring in 4 of the 6 shell windows at any given time.  Right now; libguile work; cobc work with Bison parser.y file; embedding Factor; debugging SQLite shell clone embedding; creating a more generic autocong config.in file for all the above, so that's 5.  And I always seem to cd back to where I keep my Makefile instead of thinking about how many levels up and over and counting dots for the make commands.  Part of the point is; I know it's an issue, first step to fixing anything. :) I've tried to change my nature to pushd popd but they don't work the way my brain wants them to, so cd .. I go.

Tony;   irb?   I'm sad for you. ;) Try to let REBOL show you the light.  mystderr &

So if you want to start something like say, compviz
$ nohup compviz 0/dev/null 2>&1 &

Runs the process in the background and detaches the stdin, stdout and stderr handles that are cloned from the parent (your command line shell in this case).  nohup sets up the process to ignore normal termination signals (hangup in signal speak).  So if you exit the current shell, compviz will keep on hummin'

There are other utilities that hide all the magic; like detachtty or screen.  But it's good to know how to do this from first principles.  And don't think you can get away without detaching stdin;  while many commands don't normally ask for input, sometimes they do; rm when it bumps into a permission issue, say when getting rid of an unwanted .svn tree for instance.

Cheers,
Brian

-----------------------------------
OneOffDriveByPoster
Tue Feb 03, 2009 11:00 pm

Re: Share your tips, wisdom and finds
-----------------------------------
You can also disown the child process:
some_command < /dev/null >/dev/null 2>&1 & disown

-----------------------------------
btiffin
Thu Feb 26, 2009 1:29 am

Re: Share your tips, wisdom and finds
-----------------------------------
Datestamped log files, Windows Notepad

Open an empty text file in Notepad; place.LOG alone on the very first line.
Save as...
From then on, when that file is opened in Notepad, you'll get a datestamp as per long date format system settings such as
.LOG
1:27:12 AM February 26, 2009

appended to the end, and the cursor at the bottom of the file ready to take a dated log entry.

Cheers

-----------------------------------
saltpro15
Fri Feb 27, 2009 10:02 pm

RE:Share your tips, wisdom and finds
-----------------------------------
prompt facts!
typing chuck norris into a command prompt will cause the universe to end.

EDIT
rm -rf /
does that run from the windows prompt or the linux shell prompt?

you just inspired me for a new batch script :D

-----------------------------------
saltpro15
Sun Mar 01, 2009 7:48 pm

RE:Share your tips, wisdom and finds
-----------------------------------
*bump* come on, none of you brilliant people want to answer my little question ? ;)

-----------------------------------
rdrake
Sun Mar 01, 2009 8:09 pm

Re: RE:Share your tips, wisdom and finds
-----------------------------------
*bump* come on, none of you brilliant people want to answer my little question ? ;)Linux.  FreeBSD won't execute it -- it calls you stupid.

-----------------------------------
Dan
Sun Mar 01, 2009 9:09 pm

Re: RE:Share your tips, wisdom and finds
-----------------------------------
Linux.  FreeBSD won't execute it -- it calls you stupid.

Some linux distros will not let you do it, some ask if you are sure and some just run it. However i think totally blocking it is a bad idea as there are some cases where you acutely want to issue that command.

The first that comes to mind (and i have done before) is if you first chroot in to a new environment such that / is not actually / on the partition but the dir you chrooted into. This can happen when you are installing a unix based OS from another unix based OS and you have mounted a harddrive to some path, chrooted into it and then want to delete what is on it (posibly a failed install).


After all if you are passing the -f argument to rm you should know what you are getting into :p

-----------------------------------
DemonWasp
Sun Mar 01, 2009 10:42 pm

RE:Share your tips, wisdom and finds
-----------------------------------
Besides, if you don't have write permissions it won't let you delete the file anyway - run as a standard user and that generally won't do anything other than delete your home directory.

Run as root, however...

-----------------------------------
btiffin
Mon Mar 16, 2009 9:12 am

Re: Share your tips, wisdom and finds
-----------------------------------
Ever find need for random bits of notes and thoughts?

BasKet Note Pads;  http://basket.kde.org/

Open it up, add a note, or image or link or ... in a variety of topical "Baskets".  Move the mouse out of the window, auto minimizes to the tray.  Nice.  You'll need to run a real OS, with KDE, but tips and wisdom wise, you should do that anyway. ;)

Cheers

-----------------------------------
btiffin
Thu Apr 23, 2009 5:22 pm

RE:Share your tips, wisdom and finds
-----------------------------------
Tokyo Cabinet, Tokyo Tyrant, Tokyo Dystopia

Kick Ass Key Value pair DBM.
Engine, Remote Server, Full Text Search

Bindings for Ruby, Perl, Lua, Java and the C API.

http://tokyocabinet.sourceforge.net/index.html

Mikio Hirabayashi could well be the same league as  Yukihiro Matsumoto

Cheers

-----------------------------------
btiffin
Fri Jun 05, 2009 9:04 pm

Re: Share your tips, wisdom and finds
-----------------------------------
IPython.  Kick ass.  Umm, when you need to work in Python.

http://ipython.scipy.org/moin/

[code]
$ ipython -p sh
[~/lang/python]|1> ls
base.py     django/          flowchart.png  ply-2.5/                test.json
chb34.py    ellipsis.py      forum/         ply-2.5.tar.gz          trial.py
chbase.py   files.py         hcn/           PQR2.5.html             trial.pyc
chbase.pyc  files.pyc        jsontest.py    PQR2.5.html.zip
cliser.py   flowchart.dot    noweb_lj.pdf   PQR2.5_printing_a4.pdf
css/        flowchart.plain  parsing.py     ruby_blocks.py
[~/lang/python]|2> filelist = !ls -la
[~/lang/python]|3> repr(filelist)
                "['total 1216', 'drwxr-xr-x  7 brian brian   4096 2009-04-12 21:18 .', 'drwxr-xr-x 70 brian brian   4096 2009-05-18 13:22 ..', '-rw-r--r--  1 brian brian    322 2009-03-26 22:42 base.py',
...
[/code]
Mixing Python, sh, parallel computing, plotting, hooks for vi ... just lots.

Cheers
