Archive

Archive for the ‘shell’ Category

Piping text to the clipboard in Vista and Windows 7

May 31st, 2010 niels No comments

Microsoft added a new command line tool to Vista and Windows 7: clip.exe. This nifty little utility allows user to copy program output to the clipboard on the windows command line. Its usage is pretty straightforward:

dir | clip – copies the output of the dir command to the clipboard
clip < example.txt – copy the contents of the file example.txt to the clipboard

How To Restore A SQL Server Database via SQLCMD

November 11th, 2009 niels No comments

Run this with SQLCMD to restore a SQL Server database:

RESTORE DATABASE MyDatabase
FROM DISK = 'd:\backup\MyDatabase.bak'

It’s that simple.
Thanks to Michael Otey @ SQL Server Magazine.

Tags:

How to Create MD5 Checksums On Windows

October 28th, 2009 niels No comments

There are many md5 utilities for Windows, but very few that  …

  • are free/open source,
  • create checksums for multiple files,
  • export checksums to a file,
  • and verify md5 sums from a list of files.

In short: if you need a very good tool, then use the Swiss File Knife (sfk).

For creating checksums for all your files in the current directory and storing the individual checksums in checksum.md5, execute this:

sfk md5gento checksum.md5 .

And for validating the checksums of all files in the current directory, execute this:

sfk md5check checksum.md5

That’s it :)

Tags: , ,

Unix/Linux Command Overview

August 19th, 2009 niels No comments

You are new to *nix and/or you need a concise overview of your new toys’ command line tools? Then don’t miss the Unix Toolbox!

Whether you are looking for a handy summary to carry around, or a help to get started quickly – this is what you are looking for.

Tags:

Linux Bash Command Chaining

July 9th, 2009 niels No comments

Zivo wrote a great post on the simple logic of chaining/ANDing/ORing Bash commands:

*snip*

Command Chaining:

TO run a -> b -> c

ls -lF /etc; pwd;who;ps


Logical ANDing:

Program b will execute only if program a was executed
a&&b&&c

Programs run mutually inclusive
Returns a exit status 0 and then run b exit status 0 and then run C

Logical ANDing – runs subsequent based on exit status of 0

ls -l /etc/resolv.conf && grep name /etc/resolv.conf


Logical ORing:

Run subsequent program based on failure of previous

ls -l /etc/resolve.conf || grep name /etc/resolv.conf

Example:

If the file text.txt doesnt exist you can create with ORing

ls -l test.txt || touch test.txt

Combining ANDing ORing

-bash-3.00$ ls -l text.txt || touch test.txt && ls -ltr test.txt
text.txt: No such file or directory
-rw-r--r-- 1 carlosap other 0 Aug 22 00:13 test.txt


BASH for LOOPS

text.txt
1
2
3

LOOPS SYNTAX:
for variable in list; do command variable; done


-bash-3.00$ for i in `cat test.txt`; do echo $i; done
1
2
3
-bash-3.00$ for i in `cat test.txt`; do echo test$i; done
test1
test2
test3

*snap*

Tags: