
Terminal - Commands by b_t - 19 results
This is sample output - yours may be different.
$ cat my_months
apr 789
feb 356
jan 982
jul 902
oct 876
sep 342
feb 267
may 534
mar 888
jun 654
dec 732
jun 672
nov 623
$ sort -M my_months
jan 982
feb 267
feb 356
mar 888
apr 789
may 534
jun 654
jun 672
jul 902
sep 342
oct 876
nov 623
dec 732
sort command can sort month-wise (first three letters of each month).
See the sample output for clarification.
Sorting Stable ? NO. Take note if that matters to you.
Sample output suggests that sort performs unstable
sorting (see the relative order of two 'feb' entries).
$ history -a #in one shell , and $ history -r #in another running shell
This is sample output - yours may be different.
## In shell one ##
$ find -iname "*pdf*"
<some output>
$ history -a #You don't need this if you set PROMPT_COMMAND="history -a;$PROMPT_COMMAND" manually or in your ~/.profile or ~/.bashrc
## Switch to another running shell ##
$ #Up arrow does not show the above 'find' command, so do following:
$ history -r
$ find -iname "*pdf*" #Up arrow now shows the 'find' command
By default bash history of a shell is appended (appended on Ubuntu by default: Look for 'shopt -s histappend' in ~/.bashrc) to history file only after that shell exits.
Although after having written to the history file, other running shells do *not* inherit
that history - only newly launched shells do.
This pair of commands alleviate that.
function whichpkg() { readlink -f "$(which $1)" | xargs --no-run-if-empty dpkg -S; }
This is sample output - yours may be different.
$ function whichpkg(){ readlink -f "$(which $1)" | xargs --no-run-if-empty dpkg -S; }
$whichpkg rlogin
openssh-client: /usr/bin/ssh
This revision to my command (command #8851) was called for when it failed to find the parent
package of 'rlogin', which is really a deep symbolic link to /usr/bin/ssh.
This revision fixes this newfound issue, while ensuring fixes of other older issues work too.
This is sample output - yours may be different.
$ date
Thu Oct 27 11:25:51 EST 2011
$ !! #COMMAND EXECUTED INSTANTLY
date
Thu Oct 27 11:25:54 EST 2011
$ shopt -s histverify
$ date
Thu Oct 27 11:26:05 EST 2011
$ !!
$ date #COMMAND WAITING TO BE VERIFIED/EDITED. PRESS ENTER WHEN DONE.
Bash history commands are those that begin with the character !
(eg. the most popular 'sudo !!' Explained here => http://www.commandlinefu.com/commands/view/13).
By default bash immediately executes the history command.
Setting this shell option will make bash first allow you to verify/edit an
history command before executing it.
To set this option permanently, put this command in ~/.profile or ~/.bashrc file.
To unset this option issue following command.
shopt -u histverify
whichpkg () { dpkg -S $1 | egrep -w $(readlink -f "$(which $1)")$; }
This is sample output - yours may be different.
$ whichpkg write
bsdmainutils: /usr/bin/bsd-write
$ whichpkg telnet
telnet: /usr/bin/telnet.netkit
$ whichpkg ftp
ftp: /usr/bin/netkit-ftp
Advanced revision to the command 8776 . This revision follows symbolic links.
The quotation-marks surrounding $(which $1) allows for graceful handling of errors ( ie. readlink does not complain incase 'which' command generates (null) output)
function summpkg { dpkg -s $(dpkg -S $1 | egrep -w $(which $1)$ | awk -F: '{print $1}') ; }
This is sample output - yours may be different.
$ summpkg nm
Package: binutils
Status: install ok installed
Priority: optional
Section: devel
Installed-Size: 9592
Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Architecture: i386
Version: 2.20.1-3ubuntu7.1
Replaces: binutils-gold (<< 2.20-5)
Provides: elf-binutils
Depends: libc6 (>= 2.11), zlib1g (>= 1:1.1.4)
Suggests: binutils-doc (>= 2.20.1-3ubuntu7.1)
Conflicts: elf-binutils, gas, modutils (<< 2.4.19-1)
Description: The GNU assembler, linker and binary utilities
The programs in this package are used to assemble, link and manipulate
binary and object files. They may be used in conjunction with a compiler
and various libraries to build programs.
Original-Maintainer: Matthias Klose <doko@debian.org>
This version builds on my command 8776 (Find the package a command belongs to on debian-based distros). So if you use that command to find package name then you could alternatively use following for
package summary:
function summpkg { dpkg -s $(whichpkg $1 | awk -F: '{print $1}'); }
function whichpkg { dpkg -S $1 | egrep -w $(which $1)$; }
This is sample output - yours may be different.
$ whichpkg cron
cron: /usr/sbin/cron
$ whichpkg ls
coreutils: /bin/ls
$ whichpkg intentionally-non-existent
dpkg: *intentionally-non-existent* not found.
Similar to command 7822, but handles errors gracefully.
curl -s http://example.com | grep -o -P "<a.*href.*>" | grep -o "http.*.pdf" | xargs -d"\n" -n1 wget -c
This is sample output - yours may be different.
This example command fetches 'example.com' webpage and then fetches+saves all PDF files listed (linked to) on that webpage.
[*Note: of course there are no PDFs on example.com. This is just an example]
make -d | egrep --color -i '(considering|older|newer|remake)'
This is sample output - yours may be different.
$ make -d | egrep --color -i '(considering|older|newer|remake)'
Considering target file `Makefile'.
No need to remake target `Makefile'.
Considering target file `hffcmprss'.
Considering target file `hffcmprss.o'.
Considering target file `common/common_types.h'.
No need to remake target `common/common_types.h'.
Considering target file `gnrcheap/gnrcheap.o'.
Considering target file `gnrcheap/gnrcheap.c'.
No need to remake target `gnrcheap/gnrcheap.c'.
Considering target file `gnrcheap/gnrcheap.h'.
No need to remake target `gnrcheap/gnrcheap.h'.
Prerequisite `gnrcheap/gnrcheap.c' is older than target `gnrcheap/gnrcheap.o'.
Prerequisite `gnrcheap/gnrcheap.h' is older than target `gnrcheap/gnrcheap.o'.
Prerequisite `Makefile' is older than target `gnrcheap/gnrcheap.o'.
No need to remake target `gnrcheap/gnrcheap.o'.
Considering target file `gnrcqueue/gnrcqueue.o'.
Considering target file `gnrcqueue/gnrcqueue.c'.
No need to remake target `gnrcqueue/gnrcqueue.c'.
Considering target file `gnrcqueue/gnrcqueue.h'.
No need to remake target `gnrcqueue/gnrcqueue.h'.
Prerequisite `gnrcqueue/gnrcqueue.c' is older than target `gnrcqueue/gnrcqueue.o'.
Prerequisite `gnrcqueue/gnrcqueue.h' is older than target `gnrcqueue/gnrcqueue.o'.
Prerequisite `Makefile' is older than target `gnrcqueue/gnrcqueue.o'.
No need to remake target `gnrcqueue/gnrcqueue.o'.
Considering target file `gnrclist/gnrclist.o'.
Considering target file `gnrclist/gnrclist.c'.
No need to remake target `gnrclist/gnrclist.c'.
Considering target file `gnrclist/gnrclist.h'.
No need to remake target `gnrclist/gnrclist.h'.
Prerequisite `gnrclist/gnrclist.c' is older than target `gnrclist/gnrclist.o'.
Prerequisite `gnrclist/gnrclist.h' is older than target `gnrclist/gnrclist.o'.
Prerequisite `Makefile' is older than target `gnrclist/gnrclist.o'.
No need to remake target `gnrclist/gnrclist.o'.
Considering target file `gnrctree/gnrctree.o'.
Considering target file `gnrctree/gnrctree.c'.
No need to remake target `gnrctree/gnrctree.c'.
Considering target file `gnrctree/gnrctree.h'.
No need to remake target `gnrctree/gnrctree.h'.
Prerequisite `gnrctree/gnrctree.c' is newer than target `gnrctree/gnrctree.o'.
Prerequisite `gnrctree/gnrctree.h' is older than target `gnrctree/gnrctree.o'.
Prerequisite `Makefile' is older than target `gnrctree/gnrctree.o'.
Must remake target `gnrctree/gnrctree.o'.
gnrctree/gnrctree.c: In function ?gnrctree_bfs?:
gnrctree/gnrctree.c:99: warning: suggest parentheses around assignment used as truth value
Considering target file `hfftypes.h'.
No need to remake target `hfftypes.h'.
Considering target file `hffcmprss.h'.
No need to remake target `hffcmprss.h'.
Considering target file `hffcmprss.c'.
No need to remake target `hffcmprss.c'.
Prerequisite `common/common_types.h' is older than target `hffcmprss.o'.
Prerequisite `gnrcheap/gnrcheap.o' is older than target `hffcmprss.o'.
Prerequisite `gnrcqueue/gnrcqueue.o' is older than target `hffcmprss.o'.
Prerequisite `gnrclist/gnrclist.o' is older than target `hffcmprss.o'.
Prerequisite `gnrctree/gnrctree.o' is newer than target `hffcmprss.o'.
Prerequisite `hfftypes.h' is older than target `hffcmprss.o'.
Prerequisite `hffcmprss.h' is newer than target `hffcmprss.o'.
Prerequisite `hffcmprss.c' is older than target `hffcmprss.o'.
Prerequisite `Makefile' is older than target `hffcmprss.o'.
Must remake target `hffcmprss.o'.
Prerequisite `hffcmprss.o' is newer than target `hffcmprss'.
Prerequisite `Makefile' is older than target `hffcmprss'.
Must remake target `hffcmprss'.
Say your dependencies specified in your Makefile (or dates on your source files) is causing 'make' to
skip some source-files (that it should not) or on the other other end, if it is causing make to always build some source-files regardless of dates of target, then above command is handy to find out what 'make' thinks of your date v/s target date-wise or what dependencies are in make's view-point.
The egrep part removes the extra noise, that you might want to avoid.
git push origin :featureless
This is sample output - yours may be different.
$ git push origin :featureless
To git@github.com:yourname/yourproject.git
- [deleted] featureless
This is sample output - yours may be different.
7FILESTARTWITHNUMBER
AUTHORS
CODING
COPYING
FAQ
INSTALL
MYTEST1
NEWS
NUM2INBETWEEN
README
TODO
Some source package have many 'README' kind of files, among many other regular files/directories. This command could be useful when one wants to list only 'README' kind of files among jungle of other files. (e.g. I came across this situation after downloading source for module-init-tools)
Warning: This command would miss a file like => README.1 (or one with spaces in-between)
Corrections welcome.
This is sample output - yours may be different.
This command seems to achieve the similar/same goal.
history | awk '{print $2,$3}' | sed s/sudo// | awk '{print $1}' | awk 'BEGIN {FS="|"}{print $1}' | sort | uniq -c | sort -n | tail | sort -nr
This is sample output - yours may be different.
Your version works fine except for someone who's interested in commands 'sudo' was prefixed to
i.e. in your command, use of sudo appears as number of times sudo was used.
Slight variation in my command peeks into what commands sudo was used for and counts the command
(ignores 'sudo')
lst=`dpkg -L iptables` ; for f in $lst; do if [ -x $f ] && [ ! -d $f ] ; then echo $f; fi; done;
This is sample output - yours may be different.
/sbin/iptables
/sbin/iptables-save
/sbin/iptables-restore
/sbin/iptables-xml
/sbin/ip6tables
/sbin/ip6tables-save
/sbin/ip6tables-restore
I wanted to view only executables installed by a package. This seemed to work.
There's got to be easier way, please share.
Note:
(1) Replace iptables with the package name of your interest
(2) The command will trash any existing environment variable named 'lst'
(3) Instead if you are interested in viewing just .ko or .so files installed by this package, then
that would be easy:
$ dpkg -L iptables | grep "\.[sk]o$"
This is sample output - yours may be different.
Overview of noun wonder
The noun wonder has 3 senses (first 3 from tagged texts)
1. (5) wonder, wonderment, admiration -- (the feeling aroused by something strange and surprising)
2. (4) wonder, marvel -- (something that causes feelings of wonder; "the wonders of modern science")
3. (4) curiosity, wonder -- (a state in which you want to learn more about something)
Overview of verb wonder
The verb wonder has 3 senses (first 3 from tagged texts)
1. (58) wonder, inquire, enquire -- (have a wish or desire to know something; "He wondered who had built this beautiful church")
2. (41) wonder, question -- (place in doubt or express doubtful speculation; "I wonder whether this was the right thing to do"; "she wondered whether it would snow tonight")
3. (2) wonder, marvel -- (be amazed at; "We marvelled at the child's linguistic abilities")
Note:
1) Replace 'wonder' with any word you looking the meaning for in the above example
2) Need to install these packages:
wordnet & wordnet-base (latter should be automatically installed because of dependency)
3) Combined size of packages is about 30MB on my old ubuntu system (I find it worth it)
gksudo gedit /etc/passwd &
This is sample output - yours may be different.
Need package: gksu
Note:
Launching gui app in background that needs sudo, won't work great with our old
friendly style of launching:
sudo gedit /etc/passwd &
because this would put sudo in background !
Using gksudo as demonstrated, would popup a gui sudo window.
May be this is a common knowledge, but not knowing this
frustrated me during my newbie year.
This is sample output - yours may be different.
[does not produce any output]
By default sudo 'remembers' password for a few minutes, so that you do not need to re-enter password for a series of sudo commands that might follow within a short time duration.
However, sometime you might want sudo to instantly 'forget' the password.
(Next sudo command will need you to reenter the password)
Credit: I first learned this while listening to one of the 'tuxradar' podcast.
watch -n 900 "notify-send -t 10000 'Look away. Rest your eyes'"
This is sample output - yours may be different.
Note:
1) -n option of watch accepts seconds
2) -t option of notify-send accepts milliseconds
3) All quotes stated in the given example are required if notification
message is more than a word.
4) I couldn't get this to run in background (use of & at the end fails). Any
suggestions/improvements welcome.
file /bin/* | msort -j -l -n-1 -n2 2> /dev/null
This is sample output - yours may be different.
.
.
/bin/zgrep: Bourne-Again shell script text executable
/bin/zless: Bourne-Again shell script text executable
/bin/setupcon: POSIX shell script text executable
/bin/bzmore: POSIX shell script text executable
/bin/unicode_start: POSIX shell script text executable
/bin/which: POSIX shell script text executable
.
.
/bin/more: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.6.8, dynamically linked (uses shared libs), stripped
/bin/false: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.6.8, dynamically linked (uses shared libs), stripped
.
.
Notes:
1) -n-1 means sort key is the last field
2) -l is important if each separate record is on a new line (usually so for text files)
3) -j tells msort not to create log file (msort.log) in the working directory
4) may need to install msort package.
5) msort does lot more. Check man msort