Using "wmic get * /value" within any Cygwin shell will return lots of Win/Dos newline junk ie "^M$" at the end of found value line, two lines ("$" Unix newline) above, and three below. This makes storing and or evaluating wmic queries as variables a pain. The method i suggest strips the mentioned junk, only returns the value after "OSArchitecture=", and includes only one Unix style newline. Other methods using sed|awk|cut can only handle the output of wmic cleanly when piped or using multiple sed statements.
wmic OS get OSArchitecture /value | sed 's/\r//g;s/^M$//;/^$/d;s/.*=//'
making
wmic OS get OSArchitecture /value | grep -Eo '[^=]*$'
a much cleaner and slightly less costly alternative.
Show Sample Output
Filter entries in OpenSuse /var/log/messages like: timestamp servername kernel: [83242.108090] btrfs: checksum error at logical 1592344576 on dev /dev/sda5, sector 5223584, root 5, inode 2652, offset 282624, length 4096, links 1 (path: log/warn) Show Sample Output
Use awk simple function to find maximum value in a list saved into file. change with column number and with your file If use grep variant compile your grep use pipe and paste this command without file name value. For finding both max and min values use: awk 'function max(x){i=0;for(val in x){if(ix[val]){i=x[val];}}return i;} /^#/{next} {a[$]=$;next} END{minimum=min(a);maximum=max(a);print "Max = "maximum" and Min_value = "minimum}'
My variant on this common function. Some highlights: Allows you to override the default ps args of "aux" Uses bracket trick to omit the grep process itself without having to use a second grep Always prints the correct header row of ps output Limitations: Ugly ps error output if you forget to quote your multi word grep argument Show Sample Output
This uses fetchmail to issue an etrn command that causes the MTA on the secondary mail server to process the queue for the specified domain.
You can also just use telnet or nc to connect to port 25 of the server and then:
etrn yourdomain.example.org
250 2.0.0 Queuing for node yourdomain.example.org started
Show Sample Output
same as
grep -lL "foo" $(grep -l bar *cl*.log)
In Mac OS X, by default, you have to click the mouse on a Terminal window before you can type in it. You can change this behavior to mimic the X11 behavior of focusing on the window on mouseover.
JSON version. Additionally it may give your geolocation if it's known by hostip.info Show Sample Output
In case of mailbox recovery and duplicated task/appointment reminders afterwards.
This will check if a user is logged in using ssh and will log out the user automatically after the specified time in seconds without data retrieval on the server side. Will work with bash and zsh so put it into your sourced shell file on the server side. Be aware that users can change this themselves as it's just a envoronment variable. Show Sample Output
btrfs checksum errors console report. Show Sample Output
See The Disappearance of Haruhi Suzumiya OVA on 94-96 minute for promt source. Show Sample Output
Print a random number between 1 and 50 with a normal distribution around the center. The numbers around the middle are the most likely to occur and the farther you get from that the less and less common they are. You can test this and observe the number distribution with this command:
for i in `seq 100000`; do echo $[(${RANDOM}%40+${RANDOM}%40)/2+1]; done | sort -n | uniq -c
Show Sample Output
commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.
Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.
» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10
Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):
Subscribe to the feed for: