How I may help
LinkedIn Profile Email me!
Call me using Skype client on your machine Click here to load this page in its own browser frame.

Reload this page Operating Systems & Commands

Here are my notes on the most popular computer systems and the commands to control them, shown side-by-side. Let me know what you find helpful or missing.

 

Topics this page:

  • OS Kernels
  • Shells Features
  • Command Syntax
  • Command History
  • Keyboard Operations
  • Users
  • Permissions
  • CPU Info
  • CPU Memory
  • Process Memory
  • Process Forking
  • Machine Control
  • Network Control
  • Services/Daemons
  • Disk Utilities
  • Folder/ Directory Cmds
  • File Listings
  • File Types
  • File Attributes
  • File Manipulation
  • Redirection & Piping
  • File Utilities
  • Pattern Matching
  • Randomizers
  • Your comments???
  •  

    Site Map List all pages on this site 
    About this site About this site 
    Go to first topic Go to Bottom of this page


    tool Sysinfo by Microsoft and MagniComp details system hardware, software, OS configuration, and storage asset management and configuration data in multiple platform agnostic formats.

    webpage article Microsoft FAQ on command processor scripts

    webpage article UNIX for DOS users

    Set screen Operating System Kernels

      Flavor Product uname -r Released
      Microsoft  
      - IRIX
      AT&T SVR4 (System V Release 4)
      Berkeley Software FreeBSD
      - NetBSD
      Hewlett Packard HP-UX
      SunSoft SunOS 5.8
      Solaris  
      IBM AIX
      Linuxanother page on this site Red Hat 9 2.4.20-6smp
      Red Hat Enterprise Linux 2.4.21-4.ELsmp
      Mandrake, Caldera, etc.  

      This comparison of features across Unix implementations from Puppet, a cross-Unix administration tool.

      Windows applications, such as Crossover Office, can be run on Linux (with varying success) by using Wine, an open source implementation of the Windows API running on top of Linux OS's.

      In the early 1980s, Richard Stallman began the Open Source movement within the software industry by preaching that software should be free in that source code should be shipped with the software product because users:

      • should not have to wait for bug fixes to be published by the developer.
      • should be able to add features which can be contributed back to the source community for everyone's benefit.
      • are not forced to deal with a developer who might or might not support that user's intentions for the software.
      • should use code exposed to the scrutiny of many programmers (resulting in higher quality than secret code)

      another page on this siteWindows Management Instrumentation (WMI) is based on the Common Information Model (CIM)A website external to this site supported by the Desktop Management Taskforce (DMTF)A website external to this site

      ebook Making UNIX and Windows NT Talk by Nadelson, Mark.; Hagan, Tom (Lawrence, Kan. CMP Books, 2000)

      ebook Windows 2000 & Unix Integration Guide by Burnett, Steven Forrest.; Gunter, David.; Gunter, Lola. (Berkeley, Calif. McGraw-Hill Professional, 2000)

      Linux can serve Windows clients via the Samba package.

      Caution Installing Windows clobbers the dual-boot disk created when Linux is installed.

      tool Memconf by Tom Schmidt is a Perl5 script that displays the size of each SIMM/DIMM memory module installed in Sun/HP-UX systems. Listed in the SunManagers FAQ.

      tool Poof! by Kilowatt Software provides 135 Windows command line tools. use it instead of
      tool Microsoft NT Power Toys which has been removed from Microsoft's website.

      tool SlickRun is a free floating command line utility for Windows so that command aliases (known as MagicWords) provide instant access to any program or website.


    Go to Top of this page.
    Previous topic this page
    Next topic this page

    Set screen Command Interpreter Shells -- Their Prompts and History

      Shell Command Default
      Prompt
      Initialization File History
      MSDOS cmd > AUTOEXEC.BAT Began as CP/M from Gary Kildall. Purchased by Microsoft in the mid 1970's for the IBM PC. Ended at version 6.22 (7.1 within OEM Windows 95B)
      PCDOS cmd > AUTOEXEC.BAT Jointly developed by Microsoft and IBM until version 5.
      - DRDOS > AUTOEXEC.BAT Developed by Digital Research, then purchased by Novell, then Caldera/Lineo in 1999.
      Bourne
      Shell
      sh

      &

      bsh

      $ .profile Developed at AT&T by Stephen R. Bourne in the early 1970s. It was the original and official shell distributed by AT&T and its successor, Unix System Laboratories, now owned by Novell. Considered the fastest, most portable, and easiest shell to learn, it lacked command historyon this page and command editing. It's what Oracle provides by default.
      Shell scripts developed for public use are usually written in the Bourne shell language and assume a System V Release 1 environment.
      Bourne
      Again
      Shell
      bash $ .profile & .bash_profile Created for use in the GNU project started by Richard Stallman of the Free Software Foundation (FSF) to replace all commercial UNIX utilities with freely distributable copyleft. Written by Brian Fox from Sunday, January 10, 1988 until 1993 when Chet Ramey became the official maintainer.
      C csh % .login .cshrc (for settings) Developed by William Joy (later Sun Microsystems' chief technology officer) and others at UC Berkeley during the early 1980s for C programming flexiblity. Provides the most shortcuts, but is slower than other shells.
      Korn ksh $ - Developed by David Korn in the early 1980s. It combines many of the best features of earlier command processors, so is considered a superset of the Bourne shell.
      POSIX sh $ - IEEE Std 1003.1 and IEEE Std 1003.2 supported by SunOS and Solaris
      Microsoft Shell msh > - Product code named "MONAD" in the 2004 Longhorn release of Windows provides manipulation of .NET objects and new WinFS type queries. Introduces user-declared System.Management.Automation namespace "commandlets" like unix pipes and "-whatif" directive for testing them.

      The C shell and Korn shell is preferred over the original Bourne shell which did not have command history capability.


    Go to Top of this page.
    Previous topic this page
    Next topic this page

    Set screen Shell Feature Comparison

     

     
    Go to Top of this page.
    Previous topic this page
    Next topic this page

    Set screen Command Syntax

    • A command names an executable file stored in a directory on disk. It is referred to as static because it represents potential action.
    • Most commands, with few variations, take the form:

        command [option] [source file(s)] [target file]

    • Orthogonal ?
    • A program, such as sort, that takes standard input and creates standard output is sometimes called a filter.
    • The ampersand (&) at the end of a command requests background processing. The system responds with a process number before returning control of the screen to the user.

      FunctionUNIX commandDOS command
      Find commands apropos to given text "HTTP" apropos "HTTP"  
      Get a short description of the command "print" whatis print  
      Read the manual on the command "print"
      webpage article Linux Man Pages on User commands, Sysadmin, devices, File Formats, System Calls, Libc.
      man print help print
      Search manual (whatis database on the MANPATH) for topics beginning with the word &auot;printing" man -k print  
      Clear screen. clear
      (or Ctrl+L)
      cls
      What version of the kernel am I using? uname -r ver
      What directory is the shell located? (e.g., /bin/bash) echo $SHELL
      What distribution am I using? (e.g., RedHat Linux 9) cat /etc/issue

     
    Go to Top of this page.
    Previous topic this page
    Next topic this page

    Set screen Keyboard Operations

      Action UNIX stty DOS
      Alternative to Enter Ctrl-J or Ctrl-M  
      Retrieve last command Esc-K from vi F3
      Clear Screen Ctrl-L -
      Backspace: Erase last character typed Ctrl-H or # Backspace key
      Kill all the way back to the prompt (without executing it) @ or Ctrl-U or Ctrl-X Ctrl-C
      Stop Ctrl-Z or q -
      Exit / End of file Ctrl-D Ctrl-Z
      Scroll forward spacebar  
      Scroll back up arrow  
      Stop scrolling Ctrl-S  
      Resume scrolling Ctrl-Q Ctrl-Q
      Swap Command line to KDE Alt+F8  
      Swap KDE to Command line Ctrl+Alt+F1  

     

    More on MS keyboard shortcuts

    In the UNIX Korn shell, this command prevents users from being logged off the system when Ctrl-D is pressed:

      set -o

     
    Go to Top of this page.
    Previous topic this page
    Next topic this page

    Set screen Command History

      Command history capability enables users to edit command lines and re-execute commands without retyping.

      The UNIX BASH shell remembers the last several commands entered in the command line. The number of history events saved depends on the HISTSIZE environment variable. This command history can be viewed by the command prompt:

        history

      Retrieve specific commands several ways:

      • press the UP ARROW or DOWN ARROW at the command prompt
      • preceded by "!", enter the event number in the history list

          !49

      • enter the offset from the highest entry in the history list. For example, if there were 53 events in the history list, this executes event number 51

          !-3

     
    Go to Top of this page.
    Previous topic this page
    Next topic this page

    Set screen Unix Users

      Login as root when changing system files that, for the sake of system security, should only be changeable by root. These include control of initialization processes, adding a new user, printer, or file system.

      There is only one root password. So only one person should have it, but have that written down and stored in a safe.

      With UNIX, files installed by a particular user "belong" to that user and cannot be deleted by other users.

      If an application is installed by the root user, future changes to the application would require login as root. This forces the distribution of that omnipotent password. More importantly, system change logs cannot log specifically who did what.

      Create a non-root admin. account such as "tibco" to install tibco applications:

        useradd tibco
        passwd tibco
        

      This enables people to sign in with their own individual user account, then upgrade to "superuser" rights:

        sudo tibco
        

      sad face The down-side of this approach is that a single shell script cannot perform all functions typically needed in an enterprise deploy that spans several computers. So (error-prone) manual copy of files is necessary.

     
    Go to Top of this page.
    Previous topic this page
    Next topic this page

    Set screen Cross-dressing Windows as UNIX

     
    Go to Top of this page.
    Previous topic this page
    Next topic this page

    Set screen UNIX XWindows on Windows

      Products such as putty provide command-line access to UNIX boxes.

      To see XWindows on UNIX requires additional software such as Cygwin's XServer. Here are the steps:

      1. Download Cygwin, install it, and launch a Cygwin window.
      2. startx to run XServer which opens a new window.
      3. In the new window, type: xhost * to allow connections from all hosts.
      4. Open a putty window.
      5. In the putty window, type: export DISPLAY=10.1.2.3:0.0 where "10.1.2.3" is your IP address.
      6. In the putty window, cd to the install directory and execute the install program that uses XWindows. A new window (e.g., RedHat Gnome interface) should appear.

     
    Go to Top of this page.
    Previous topic this page
    Next topic this page

    Set screen Unix File Permissions

      If you create a UNIX shell script and run it, you will get a "Permission denied" message if you don't explicitly assign execute permissions with a command such as:

        chmod +x myscript.sh

      Code Permission Octal Decimal
      r-- Read only 0100 4
      -w- Write only 0010 2
      --x eXecute only 0001 1
      rwx Read, Write, eXecute 0111 7
      In Unix systems, 3 permissions can be granted: read, write, and execute (abbreviated as r, w, and x).

      Each permission is stored as one binary bit within a 4-bit number.

      Unix commands specify all three permissions at once using the decimal equivalent of the 4 bit "octal" number, so called because one can count to 8 using 4 binary bits.

        - u
      user
      g
      group
      o
      other
      ls -l - rwx r-x r--
      chmod binary   4+2+1 4+0+1 4+0+0
      chmod octal   7 5 4
      umask binary   0+0+0 0+2+0 0+2+1
      umask octal   0 2 3
      command ls -l (with the -long option) lists the 3 permissions for each category of ownership (user, group, other) along with the name of the owner and the KB of its password file.

      An octal number is used to store the permission of each category of ownership.

      Umask filename without argument echoes current permissions settings as an octal number.

      chmod 754 filename sets permissions using "7" for user, "5" for group, "4" for other.

      umask 023 filename (user mask) cause all new files to be created as if "chmod 754" were executed after their creation.

      chmod ugo+rwx filename sets permissions for all category of ownership.

        "-" instead of "+" removes the permissions.

      chmod a+r filename sets permissions for all users.

      In Solaris, to modify the default group membership of a file:

        chgrp group file

       

    ebook Auditing and Security : AS/400, NT, Unix, Networks, and Disaster Recovery Plans by Musaji, Yusufali F. (New York John Wiley & Sons, Inc. (US), 2001)

     
    Go to Top of this page.
    Previous topic this page
    Next topic this page

    Set screen CPU Information

      To get a list of the CPUs on a machine: On Solaris: /usr/sbin/psrinfo -v

      To list the RAM usage for a machine:
      Solaris ptconf|grep -i mem project/task level
      ptconf|grep -J mem processes and tasks
      psrinfo -v -
      HP/UX swapinfo -tm
      IBM AIX lsdev -C|grep mem
      lsattr El mem0
      DEC-UNIX uerf -r 300 | grep -i mem
      Linux free

      Related page: The Windows Management Interface.

     
    Go to Top of this page.
    Previous topic this page
    Next topic this page

    Set screen Determining CPU RAM Installed

      Each operating system has its own command to determine the amount of physical memory installed:

      AIX lsattr -El sys0 for the "realmem"
      Compaq Tru64 vmstat -P for the "Total Physical Memory"
      HP-UX dmesg for the Physical:
      Solaris /usr/sbin/prtconf | grep Memory for "Memory size"

      To determine the size of each memory page:

        # /usr/bin/pagesize
        8192
        

        To determine the amount of memory used (by the kernel, Anon, Exec, libs, cache, free):

        On Solaris: mdb -k


    Go to Top of this page.
    Previous topic this page
    Next topic this page

    Set screen Machine Control Commands

      Action UNIX options & filespec DOS filespec & options
      Reboot / re-start reboot -
      Shut down (halt) machine abruptly poweroff
      halt -p
      shutdown -h now
      init 6
      -
      Shut down (halt) machine gracefully shutdown -ry 10
        -a to Use file /etc/shutdown.allow
        -c to cancel scheduled shutdown.
      -
      Elapsed time (and other statistics) since last reboot uptime NET STATISTICS
      List installed patches showrev -p
      patchadd -p
      -

     
    Go to Top of this page.
    Previous topic this page
    Next topic this page

    Set screen Network Control

      Action UNIX options & filespec DOS filespec & options
      View computers on a network: ? NET VIEW
      List shares on a given machine: ? NET SHARE
      List user accounts on a given machine: ? NET USER
      List user sessions on a given machine: ? NET SESSION
      Add computer “homer” to the PDC on the local domain: ? net computer \\homer /add

     
    Go to Top of this page.
    Previous topic this page
    Next topic this page

    Set screen Processes/Services/Daemons

      A process is a sequence of actions that take place in memory. It is referred to as active because it is the work the computer does in response to the execution of commands.

      Action UNIX options & filespec DOS filespec & options
      List Windows services/UNIX processes (daemons): pstree
      ps -aux
      NET HELP START
      Start service/process - NET START service
      Stop service/process - NET STOP service
      Pause and continue started services: pstop 22121 NET PAUSE service

      NET CONTINUE service

      Kill process pkill HUP in.named Microsoft does not provide a built-in command to stop processes. However,
      tool Command Line Process Utility Freeware by Craig Peacock does the job. Alternately,
      tool pskill from sysinternals is a simpler (less featured) freeware

     
    Go to Top of this page.
    Previous topic this page
    Next topic this page

      Set screen Forking Processes

      To fork processes:

        cmd1 || cmd2 # exec cmd2 if cmd1 fail cmd1 && cmd2 # exec cmd2 if cmd1 is OK

      This example uses tee to send 1>stdout and 2>sterr separately and also both together so you can see when each occurred with respect to each other:

        ((./program 2>&1 1>&3 | tee ~/err.txt) 3>&1 1>&2 | tee ~/out.txt) > ~/mix.txt 2>&1

     
    Go to Top of this page.
    Previous topic this page
    Next topic this page

    Set screen Disk Utilities

      FunctionUNIX commandDOS command
      Total Disk Usage (in 512 byte blocks) du -s chkdsk
      Disk Usage for directories -in kilobytes df -kah -
      Disk Usage for each file du -lR -a -
      Disk Quota information DQinfo -
      Disk Quota allocation DQalloc -
      Disk Quota removal DQrm -
      Repartition FAT disk Linux fips.exe  
      Reformat disk drive system mke2fs format

      Using DOS Floppies within Linux

     
    Go to Top of this page.
    Previous topic this page
    Next topic this page

    Set screen Folder Locations

      FunctionLinuxMicrosoft
      Kernel root
      /boot
      "WINNT" or "WINDOWS"another page on this site
      Executables /usr/bin
      /usr/lib
      /usr/include
      /usr/share
      /usr/doc
      /usr/apps
      "Program Files"
      Drivers /dev Win.../System32
      hosts file /etc Win.../System32/Drivers/Etc
      One for each User /usr
      /user
      "Documents and Settings"
      Log files /var -
      Temporary work files /tmp Temp
      Optimizing Utilities /opt -

      To get a list of libraries mapped into processes on Solaris: pldd $$

     
    Go to Top of this page.
    Previous topic this page
    Next topic this page

    Set screen Folder/Directory Commands and Options

      Action UNIX options & filespec DOS filespec & options
      Check current Print Working Directory pwd cd
      Return to user's home folder cd
      cd ~
      cd /
      Up one folder cd ..
      Make directory mkdir proj1
      Remove empty directory rmdir /usr/sam rmdir
      or rd
      Remove directory -recursively rm -r rmdir /s (NT)
      deltree (Win 95)

     
    Go to Top of this page.
    Previous topic this page
    Next topic this page

    Set screen File Listing Commands and Options

      Action UNIX options & filespec DOS filespec & options
      List directory tree -recursively ls -r tree
      List last access dates of files, with hidden files ls -l -a  
      List files by reverse date ls -t -r *.* dir *.exe /o-d
      List files verbosely by size of file ls -l -s *.* dir *.* /v /os
      List files recursively including contents of other directories ls -R *.* dir *.* /s
      List file types in color ls -flai --color  
      List number of lines in folder wc -l *.xtuml
      sed -n '$='
      sed -n "$="
      List files with x anywhere in the name ls | grep x  

     
    Go to Top of this page.
    Previous topic this page
    Next topic this page

      Set screen File Type Indicators

      The "ls -l" command lists permissions for both files and directories. An example:

      LinuxUNIXFile Type Color test
      blank - Regular/normal file White -f
      / d Directory/folder Blue -d
      *   Program or executable script Green -x
      | p Named (fifo) Pipe   -p
      @ l Symbolic link Aqua -h
      =   Socket    
        b Block special file   -b
        c Character special file   -c

      The test command also uses -s for nonzero size, -w for writeable by the current user, -a for ???

     

      Use the --color parameter to always see in color:
        alias ls='ls --color'

      For no color

        unalias ls

      Definition An inode number is the address of a disk block. Two filenames with the same inode means they are aliases of the same physical file.

      To create a hard file link (within the same directory):

        ln         file1   file2

      To create a symbolic link:

        ln   -s   file1   file2

     
    Go to Top of this page.
    Previous topic this page
    Next topic this page

      Set screen File Attributes

      Microsoft uses the first letter of each attribute name (read-only, archive, system, hidden):

        Attrib [+r-r] [+a-a] [+s-s] [+h-h] [path\file] /s

        /s specifies processing of all downstream subdirectories as well.

        To remove read-only and hidden attributes from myfile located in mypath:

          Attrib -r -h \mypath\myfile

       

    ebook UNIX Filesystems : Evolution, Design, and Implementation by Steve D. Pate (Indianapolis, IN John Wiley & Sons, Inc. (US), 2003)

     
    Go to Top of this page.
    Previous topic this page
    Next topic this page

    Set screen File Manipulation Commands and Options

      To obtain a file from the internet using HTML:

        wget http://drupal.org/files/projects/drupal-x.x.tar.gz
        

        Having a bunch of these in a batch file is how you automate downloads instead of right-clicking on a link and selecting "Save Target As...".

      Action UNIX options & filespec DOS filespec & options
      To untar a tar file (used in UNIX but not recognized by WinZip8): tar -zxvf file not WinZip
      To unjar a jar (Java archive) file jar -xvf file.jar Winzip?
      Page the contents a screen at a time: spacebar forward, B for Backward, Q to Quit less   afilename  
      Peek at the first and last n lines head -n file
      tail -n file
      TYPE x.txt | MORE
      Create new (blank) file touch afilename  
      Copy old.file to new.file
      -p preserve file attributes (e.g. ownership and edit dates)
      -r copy recursively through directory structure
      -a archive, combines the flags -p -R and -d
      cp old.file new.file copy old.file new.*
      tool xxcopy
      Move old.file (-i interactive flag prompts before overwriting files) mv -i old.file /tmp Copy old.file /tmp
      del old.file
      Remove file (-intention) rm -i sam.txt del sam.txt
      Find and (blindly) remove files in the system with file types of tmp which haven't been accessed in the last 10 days find / -name "*.tmp" -atime +10 -exec rm {} \; -
      Find and prompt user mike to OK removal of files in the system with file types of tmp find /usr/home/mike -name "*.tmp" -ok rm {} \; -
      Find and print user files in the system with file types of txt find /usr/home -depth -name "*.tmp" -print edit file.txt
      Compare two files and show differences diff comp
      fc

     
    Go to Top of this page.
    Previous topic this page
    Next topic this page

    Set screen Redirection & Piping

      Each program can perform a very specific task when the datastreams from one program can be redirected to a device or piped into another command process ( like connecting garden hoses).

      Redirection & Piping Action UNIX
      Read STDIN file feed.txt and output STDOUT to file x.txt and STDERR to file err.txt ReminderThere is no space between the number and >. Specifying the same file for both input and output erases that file. readnews 0>feed.txt 1>x.txt 2>err.txt
      outputs to nowhere Reminder Do not use vi or touch commands on /dev/null. This turns it into a file, which confuses Linux start-up scripts. readnews > /dev/null
      count entries starting with "a" from a listing ls -l | grep d? | wc
      input file schedule into the mail program to output file acctng mail acctng < schedule
      Appends output of command to the bottom of AppendedFile. command >> AppendedFile
      Concatenate 3 files and pipe to line printer and tee (replicate) it to the screen as well. cat file.1 file.2 file.3 | tee lp


    Go to Top of this page.
    Previous topic this page
    Next topic this page

    Set screen File Utilities

     
    Go to Top of this page.
    Previous topic this page
    Next topic this page

    Set screen Symbolic Links

      UNIX OSs allow a "virtual" name that "redirects" references to that name to a physical file.

      To create a symbolic (pointer) link called "FileX" to "RealFile":

        ln -s /home/user/Realfile FileX

     
    Go to Top of this page.
    Previous topic this page
    Next topic this page
    Regular Expressions

    Set screen Pattern Matching

      Pattern Example
      Position ? stands for any single character ls ?1
      Position * stands for any number of characters ls 2*
      Specific characters [AB] stands for any number of characters ls [AB]1 would yield A1 and B1
      Range of characters [A-Z] stands for letters from A thru Z

      The MS-DOS CLI command Comp compares the contents of two files or two sets of files. Its syntax:

        Comp [files1] [files2] [/d] [/a] [/l] [/n=number] [/c]
      where
        files1 and files2 are the file sets for comparison.
        /d yields a decimal display.
        /a yields an alpha display.
        /l shows the line numbers for differences rather than offset.
        /n forces the line-by-line comparison for n lines, even in different length files.
        /c removes case sensitivity.

      Usage Example:

        Comp \path1\myfiles \path2\myfiles /l

        compares the files in \path1\myfiles with those in \path2\myfiles and show just the line numbers of any discrepancies.

      The MS-DOS CLI command FC (file compare) two individual files and displays content discrepancies. Its syntax:

        Fc [/a] [/b] [/c] [/l] [/lbx] [/n] [/t] [/u] [/w] [file1] [file2]
      where
        files1 and files2 are the file for comparison.
        /a yields an abbreviated display of discrepancies.
        /b specifies a binary compare (ASCII is the default for files not having a binary extension).
        /c means case-insensitive.
        /l is the ASCII compare for files having a binary extension (such as .exe).
        /lbx buffer size (the x part) for how many discrepancies Fc should tolerate before exiting.
        /n shows line numbers during ASCII compare.
        /t skips expanding tabs to spaces.
        /u performs unicode compare.
        /w skips consecutive whitespaces.

      The MS-DOS CLI command findstr (find string) in an individual file. Its syntax:

        Findstr [/b] [/e] [/l] [/c:mystring] [/r] [/s] [/i] [/x] [/v] [/n] [/m]
      where

        /b finds pattern at start of line.
        /e finds pattern at end of line.
        /l uses literal find pattern.
        /c:mystring is the string to search for.
        /r (default) searches for non-literal strings.
        /s also searches subdirectories.
        /i is insensitive for case.
        /x shows exact matching lines only.
        /v shows non-matching lines only.
        /n prints line numbers.
        /m shows matching files only.

     
    Go to Top of this page.
    Previous topic this page
    Next topic this page

      Set screen sed (stream editor)

      sed works like a find-and-replace filter. Its general format is: 's/ regexp / replacement / flags'

      This sample command from a FAQ) produces a newfile after replacing every occurrence of "Glenn" with the word "Harold":

        sed 's/Glenn/Harold/g' oldfile >newfile

      F. Curtis Michel Introduction to sed says:

        "you will almost NEVER get the command line right the first time!"

      "regex" ("Glenn" in the example above) is a regular expressionanother page on this site pattern. More examples:

        $d               # delete the last line of the file
        /[0-9]\{3\}/p    # print lines with 3 consecutive digits
        5!s/ham/cheese/  # except on line 5, replace 'ham' with 'cheese'
        /xyz/!s/aaa/bb/  # unless 'xyz' is found, replace 'aaa' with 'bb'
        17,/foo/d        # delete all lines from line 17 up to 'foo'
        

      Set screen awk

      Example: to extract some part of the content of a line searched, and rename the previous output file to the text found:

        awk 'BEGIN{FS=":"}/^DnsName/{print $2}' outputfile > newfile
        

      $63/$26 The AWK Programming Language (Addison-Wesley (Pearson): 1988) by Alfredo V. Aho, Brian W. Kernighan, and Peter J. Weinberger

      webpage article AWK

      text file text2html.awk converts a text file to html.

       

    sed was first written by Lee E. McMahon in 1974 as "A Non-interactive Text Editor". Because he made his source available, several improvements are now available.
    Eric Pement has an errata of sed versions in his sed faq:
      ssed v3.59
      GNU sed v4.0 - v4.0.5,
      GNU sed v3.02.80
      GNU sed v3.02
      GNU sed v2.05
      GNU sed v1.18
      GNU sed v1.03
      sed v1.6 (Briscoe)
      sed v1.5 (Helman)
      sedmod v1.0 (Chen)
      HP-UX sed
      SunOS sed v4.1, v5.6
      Ultrix sed v4.3
      Digital Unix sed
    Proposals for a super-sed and GNU sed 4.0 to make sed more versatile without sacrificing its speed and overall philosophy.

     
    Go to Top of this page.
    Previous topic this page
    Next topic this page

    Set screen Randomizers

      Ksh provides a variable to generate a random number between 0 and 32767:

        echo RANDOM=$RANDOM
        SECONDS # The number of seconds since the shell was invoked

     
    Go to Top of this page.
    Previous topic this page
    Next topic this page

    Set screen Iteration in Shell Scripts

      With Windows Shell scriptsanother page on this site set the default script host so you don't have to type cscript before each .vbs file execution:

        Cscript //h:cscript //s

      A sample DOS script to invoke the "Ping of Death" to crash your machine:


        @echo off
        CLS
        REM Start Task Manager:
        start /high /min taskmgr.exe
        REM
        REM Launch Internet Explorer to a site:
        start /high http://www.microsoft.com/
        REM
        REM Invoke the ping of death to crash your machine:
        for %%d in ( A B C D E F G H I J K L M N O P Q R ) do start /min ping -l 65527 -n 1000 localhost

      while ... do ...

      if who | wc -l > 1 ; then echo "There is 1 user"; else echo "There are x users" ; fi

     
    Go to Top of this page.
    Previous topic this page
    Next topic this page

    Related:

  • Windows Shell Scripting
  • Performance Monitoring (sar, etc.)
  • Shortcut Keys
  • Browsers
  • Web Development Tools
  • Website Planning
  • Java Programming
  • Portions ©Copyright 1996-2014 Wilson Mar. All rights reserved. | Privacy Policy |


    How I may help

    Send a message with your email client program


    Your rating of this page:
    Low High




    Your first name:

    Your family name:

    Your location (city, country):

    Your Email address: 




      Top of Page Go to top of page

    Support this site:

    Amazon Honor System Click Here to Pay Learn More or through Amazon

    Thank you!