The best place to *find* answers to programming/development questions, imo, however it's the *worst* place to *ask* questions (if your first question/comment doesn't get any up-rating/response, then u can't ask anymore questions--ridiculously unrealistic), but again, a great reference for *finding* answers.

My Music (Nickleus)

20131108

useful, advanced bash functionality

http://www.thegeekstuff.com/2008/08/15-examples-to-master-linux-command-line-history/#more-130

here are some examples of some useful bash functionality that i haven't used before:

// search history for most recent execution of ps command

(keyboard combination:) ctrl+r
(type:) ps

now you have two options:
* to execute the command, just hit enter
* to edit the command, just hit the right arrow key


// shorter way to search for running java processes

pgrep -lf java

(which is identical to: ps aux|grep java )


// kill the gedit process

pkill gedit



// get the last argument from the previous command to the current command

ls|grep somefile.txt
nano -w !!:$


which executes:
nano -w somefile.txt


// get the first argument from the previous command to the current command

cp file1.txt file2.txt
nano -w !^

which executes:
nano -w file1.txt



No comments:

Post a Comment