Skip to navigation | Skip to content

Share your knowledge. Make a difference.

Cygwin is a Linux-like environment for Windows

1 - I can do better 2 - Jury's out 3 - Pretty darn good 4 - Splendiferous 5 - Awesometastic (by 4 people)   Your rating: 1 - I can do better 2 - Jury's out 3 - Pretty darn good 4 - Splendiferous 5 - Awesometastic

Ranked #4980 in Tech & Geek, #110738 overall

Rated G. (Control what you see)

Best of Both Worlds Linux & Windows!

 

Cygwin installs in minutes on your PC just like any other Windows Application. It is an easy and safe way for Windows users to try out a Linux like environment. Alternatively it is an easy way for Linux users to install Linux utilities on a PC.

If Cygwin is not for you just click the uninstall button!

Download & Install Here 

Visit Cygwin.com and click on Install or update
now!




Click Here for Cygwin Documentation



Click Here for the Main Mailing List



Click here for basic tips page




Cygwin consists of hundreds of Linux utilities including grep, sed, perl, awk, find and various shells including bash and zsh.

Great Stuff on Amazon 

Windows and Linux Integration: Hands-on Solutions for a Mixed Environment

Amazon Price: $32.99 (as of 12/02/2008) Buy Now

A Practical Guide to Linux(R) Commands, Editors, and Shell Programming

Amazon Price: $31.49 (as of 12/02/2008) Buy Now

The Official Ubuntu Book (2nd Edition)

Amazon Price: $23.09 (as of 12/02/2008) Buy Now

RHCE Red Hat Certified Engineer Linux Study Guide (Exam RH302) (Certification Press)

Amazon Price: $37.79 (as of 12/02/2008) Buy Now

Classic Shell Scripting

Amazon Price: $23.07 (as of 12/02/2008) Buy Now

The Power of "The Command Line Interface" 

Cygwin is mainly accessed via a CLI although there are GUIs available. The Command Line Interface (CLI) gives users a very powerful & flexible of accessing the programs and data on their PC. Although there is of course a fairly stiff learning curve at the beginning, with time users create shell scripts which automate many of the more tedious tasks and this allows users to be become more efficient and productive

Great Stuff on eBay 

Loading Fetching new data from eBay now... please stand by
eBay

List of Basic Unix Commands 

There are many many more



  • cat --- for creating and displaying short files

  • chmod --- change permissions

  • cd --- change directory

  • cp --- for copying files

  • date --- display date

  • echo --- echo argument

  • ftp --- connect to a remote machine
    to download or upload files

  • grep --- search file

  • head --- display first part of file

  • ls --- see what files you have

  • lpr --- standard print command (see also
    print
    )

  • more --- use to read files

  • mkdir --- create directory

  • mv --- for moving and renaming files

  • ncftp --- especially good for downloading

  • print --- custom print command (see also
    lpr
    )

  • pwd --- find out what directory you are in

  • rm --- remove a file

  • rmdir --- remove directory

  • rsh --- remote shell

  • set --- set an environment variable

  • sort --- sort file

    --- display last part of file

  • telnet --- log in to another machine

  • wc --- count characters, words, lines

Cygwin Examples 

zzapper's Tips Home



Updated : 24Sep08

> zsh -fx # start a "clean" version of zsh (without your startup files)
print $ZSH_VERSION
http://zshwiki.org/
http://www.zsh.org/mla/ Searchable Mailing List Archive
http://grml.org/zsh/zsh-lovers.html
http://zsh.sunsite.dk/Doc/Release/zsh_toc.html Everything?
man zsh
man zshall

zsh Zsh overview (this section)
zshmisc Anything not fitting into the other sections
zshexpn Zsh command and parameter expansion
zshparam Zsh parameters
zshoptions Zsh options
zshbuiltins Zsh built-in functions
zshzle Zsh command line editing
zshcompwid Zsh completion widgets
zshcompsys Zsh completion system
zshcompctl Zsh completion control
zshmodules Zsh loadable modules
zshzftpsys Zsh built-in FTP client
zshall Meta-man page containing all of the above

/usr/share/zsh/htmldoc/zsh_toc.html

Global aliases
Searching and filtering my mysql database with my own utility searchdb
>searchdb client1 | grep -i website1 | fmt -50 | putclip
How you can simplify this using 3 zsh Global Aliases
>searchdb client1 G website1 F P
alias -g ND='$(ls -d *(/om[1]))' # newest directory
alias -g NF='$(ls *(.om[1]))' # newest file
Example of use
cp NF ND

!!
!$ (last argument)
!$:h (last argument, strip one level)
!$:h:h (last argument, strip two levels)
!?echo
vi !* (all parameters)
vi !$ (last parameter)
vi !^ (first previous parameter)
vi !:1 (first previous parameter)
vi !-2:2 (second parameter of second but last command)

history # View recent commands
!42 # Re-execute history command 42

# substitute previous command
r oldstr=newstr
!!:s/fred/joe/ # edit previous command replace first fred by joe
!!:s/fred/joe/ # Note : sadly no regexp available with :s///
!!:gs/fred/joe/ # edit previous command replace all fred by joe
mv Licence\ to\ Print\ Money.pdf !#^:gs/ // # rename file removing spaces
^fred^joe # edit previous command replace fred by joe
^str1^str2^:u:p # replace str1 by str2 change case and just display
echo chim
^chim^&-&ney-&-&-cheree # reuse LHS
!42:p
also use control-R
^str1^str2^:G # replace as many as possible

cd !?ls<TAB> #get command and parameters of a previous ls command
cd !?ls?:*<TAB> #get (just) parameters of a previous ls command

Generating a command from an earlier one
How to recall the parameters of a previous command, on line 7 below
recall the parameters of line 5

5> mv somefile1 /home/saket/stuff/books/
6> acroread somefile.pdf
7> mv somefile2 /home/saket/stuff/books/

> mv !?saket
Would bring up the whole line ready for a little editing

or purist

> mv !?saket?:*
Would just bring up the parameters

If you know the history number of the line (say 5) with desired parameters you can try

> !5:s/somefile1/somefile2/

and if you don't know the history number

!?saket?:s/somefile1/somefile2/

# History Substitution Summary
#For CURRENT line that you are editing (the # designates current line)
# Remember Tab will expand the following

!#:0 command
!#^ first parameter
!#:1 first parameter
!#:1-4 first 4 parameters
!#$ last parameter
!#* all parameters
!#$:s/bash/zsh perform substitution on previous parameter

cp longfilename.php backup_!#^
cp {,backup_}verylongfilename.tex # same thing
mv textfile.{txt,bak} # expands to mv textfile.txt textfile.bak

#For Previous Command (for comparison)
!-1 repeat whole command
!! repeat (shortcut)
!:0 command
!^ first parameter
!:1 first parameter
!:1-4 first 4 parameters
!$ last parameter
!* all parameters
!!:s/bash/zsh (or ^bash^zsh)
!^:t just file name of first parameter
!$:h just path of last parameter
!-2$:r just file name without extension of first parameter

For last but one command
!-2 repeat last but one command
!-2^ first parameter last but one command
!-2$ last parameter last but one command
!-2:2 second parameter of second but last command
!-2:s/bash/zsh
etc
For history command 42
!42

!:0 is the previous command name
!^, !:2, !:3, !$ are the arguments
!* is all the arguments
!-2, !-3, are earlier commands
!-2^, !-2:2, !-2$, !-2* are earlier parameters

cd !$:h (remove file name)
cat !!:t (only file name)
# Convert images (foo.gif => foo.jpg):
$ for i in **/*.gif; convert $i $i:r.jpg

print ${param:&} (last substitute)

< readme.txt # < shorthand for more

# Directory substitution (magic)
# if you were in directory
/c/inetpub/dev.somehomes.co.uk/epsystem/eppigeon/
cd dev www
#would put you in parallel directory
/c/inetpub/www.somehomes.co.uk/epsystem/eppigeon/

# filtering the output of a command conventionally
print $(history -n -1|sed 's/.* //')
# ${${(z)foo}[2]} zsh filtering mechanism
print ${${(z)$(history -n -1)}[-1]}
print ${${(z)history[$((HISTCMD-1))]}[-1]}
gvim.exe $(history -n -1 | sed "s/^[^ ]* //;s/ .*//")
print ${${(z)history[$((HISTCMD-1))]}[2]}

# ls
ls -ld **/*(/^F) # list any empty directories
print **/*(/^F) | xargs -n1 -t rmdir #delete empty directories
zargs rmdir -- ./**/*(/od) 2> /dev/null # deletes empty directories
ls ^x* # list all but x*
#list all files without an extension ( no dot)
ls *~*.*(.)
ls (x*~x3|x5) # list files x* except x3 and x5
ls **/fred*~*junk*/* # list all files fred* unless in a junk directory
gp 'host' **/(*.cfm~(ctpigeonbot|env).cfm)
grep -i 'host' **/(*.cfm~(ctpigeonbot|env).cfm)~*((#s)|/)junk*/*(.)
egrep -i "^ *mail\(" **/*.php
gp "^ *mail\(" **/*.php~*junk*/* #find all calls to mail, ignoring junk directories
ls *.h~(fred|foo).h # same thing
ls (x*~x[3-5]) # list files x* except x3 to x5
ls *[^2].php~*template* # list files with 2nd filter
ls (xx|yy) # list xx or yy
ls *.(jpg|gif) # list graphic files
ls fred{joe,sid}.pl
ls fred{09..13}.pl
ls fred<76->.pl # list all files fred76.pl to fred9999*.pl etc
ls {_,}fred.php # list files _fred.php fred.php
ls (_|)fred.php # same effect by globbing
ls *.{jpg,gif}(.N) # don't break if one or other image type absent

setopt no_case_glob # set ignore case for ls etc

# globbing modifiers
# :r removes the suffix from the result,
# :t takes away the directory part
# . means must be regular files not directories etc
# *(om[1]) picks most recently modified file
# (.N) no warning message if any file absent
ls (#i)*.pmm # case insensitive globbing (note exact syntax)
ls *(om[1]) # print the most recent file
cp *(om[1])<TAB> # will complete file name
ls *(.om[1]) # print the most recent file (not directory)
ls -l *(Om[1]) # oldest file
ls -lt **/*.tex(D.om[1,5]) # list 5 most recent files in hierarchy
# list 5 most recent files in each sub-directory
dirs=( '' **/*(DM/) ) eval 'ls ${^dirs}*(ND.om[1,5])'
ls {^dev*,}/index.php(.N) # ignore directories beginning dev*
ls **/index.php~dev*(/*)## # ignore subdirectories dev* multi-level
vi *(.om[1]^D) # vi newest file ^D means switch off GLOB_DOTS
ls -tld **/*(m-2) # list files modified in last 2 days in hierarchy
ls *(om[1,5]) # print the 5 most recent files
ls -l *(m4) # list files modified exactly 4 days ago
ls -ltd *(mw3) # list files 3 weeks old
ls -1ld *([1,10])# list just 10 files one per line , no directories
ls *(m-1) # files modified today
ls *(m0) # files modified today
vi *(m0) # re-edit all files changed today!
rm *.{aux,dvi,log,toc}(.N) # rm latex temp files N means no error msg if any file type absent
rm ./*(Om[1,-11])# removes all files but the ten newest ones (delete all but last 10 files in a directory)

ls *(n:t) # order by name strip directory
ls **/*(On:t) # recursive reverse order by name, strip directory
ls PHP*/**/*.php # recursive but only for subdirectories PHP*
ls *.c(:r) # strip suffix
ls **/*(.) # only files no directories
ls -ld *(/) # list only directories

#oddities
[[ FOO = (#i)foo ]] # case insensitive matching
fred=$((6**2 + 6)) # can do maths
: > /apache/access.log # truncate a log file

# arrays
X=(x1 x2) # create an array
print -C 1 $X # print each array element on it's own line
ls $X
print ${#path} # length of "path" array
print ${#path[1]} # length of first element in path array
print ${$( date )[2,4]} # Print words two to four of output of 'date':
array=(~/.zshenv ~/.zshrc ~/.zlogout)
filelst[$(($#filelst+1))]=$x # append (push) to an array
filelst+=($x) # append (push) to an array (better)
files=(${(f)"$(egrepcmd1l)"} ) # push a sentence to an array (where egrepcmd1l is a global alias
% print ${array:t}
.zshenv .zshrc .zlogout

# variable substitution
somevar="bu&^*ck" # variable with mucky characters
print ${somevar//[^[:alnum:]]/_} # replace all non-alphanumerics with _
echo ${file##*/} # echo just the file name
echo ${texfilepath%/*.*} # echo just the path
echo ${file%.*} # strip file extension
echo $file:r # strip file extension
echo ${0##*[!0-9]} # strip all but trailing digit from filename $0
echo ${(M)0%%<->} # strip all but trailing digit from filename
file=${1/\//C:\/} # substitute / with c:/ ANYWHERE in string
file=${1/#\//C:\/} # substitute / with c:/ Beginning of string
file=${1/%\//C:\/} # substitute / with c:/ End of string
# note # & % are using to match beginning and end

# decisions
# cd to different dri

New Amazon Plexo 

Cygwin on Wikipedia 

Cygwin () is a collection of tools originally developed by Cygnus Solutions to provide in Microsoft Windows a command line and programming interface familiar to Unix users. Programs supported by Cygwin work well on Windows NT, Windows 2000, Windows XP, and Windows Vista, and some run acceptably on Windows 9x.

While Cygwin provides programming language header files and libraries making it possible to recompile or port Unix applications for use on computers running Microsoft Windows operating systems, it does not provide binary executable programs capable of running without Cygwin installed.

Cygwin is released under the GNU General Public License; it is free software. It is maintained by employees of Red Hat, NetApp and many other volunteers. Corinna Vinschen and Christopher Faylor are currently the managers of the Cygwin development team.

Linux on Wikipedia 

Linux (commonly pronounced in English; variants exist Torvalds has made available an audio sample which indicates his own pronunciation, in English () ? ? and Swedish () ? ) is a generic term that commonly refers to Unix-like computer operating systems that use the Linux kernel. Linux is one of the most prominent examples of free software and open source development; typically all the underlying source code can be used, freely modified, and redistributed by anyone.

Linux is predominantly known for its use in servers, although it is installed on a wide variety of computer hardware, ranging from embedded devices and mobile phones to supercomputers, and its popularity as a desktop/laptop operating system is growing due to the rise of netbooks and the Ubuntu distribution of the operating system.

The name "Linux" comes from the Linux kernel, originally written in 1991 by Linus Torvalds. The system's utilities and libraries usually come from the GNU operating system, announced in 1983 by Richard Stallman. The GNU contribution is the basis for the alternative name GNU/Linux.

Linux Commands on Wikipedia 

This is a list of UNIX utilities as specified by IEEE Std 1003.1-2004, which is part of the Single UNIX Specification (SUS).

These utilities can be found on UNIX Operating systems and most UNIX-like operating systems.

Cygwin Reader Feedback 

BookNow wrote...

Great Lens! I gave you five stars. Please visit my lens and tell me what you think about it!

Linux tips and tricks

ReplyPosted November 04, 2008

X
thesuccess

About thesuccess

Are you Serious About Making Money on the Web? It's the only Recession-Proof Business there is. It's great fun as well because there are new Developments and Opportunities all the time!

successtheory.com

thesuccess's Pages

See all of thesuccess's pages

X

Happy holidays!

The red bow is special. Whenever you see a red bow on a Squidoo page, it means the page is raising money for charity.

Buy something from the page, and we'll automatically make a donation to charity, thanks to you.