Archive for October, 2007

Sams Teach Yourself Shell Programming in 24 Hours (Email web hosting)

Wednesday, October 31st, 2007

Sams Teach Yourself Shell Programming in 24 Hours Contents Index Hour 18: Miscellaneous Tools Previous Chapter Next Chapter Sections in this Chapter: The eval Command The expr Command The : Command The bc Command The type Command remsh/rsh/rcmd/remote (Remote Shell) The sleep Command Summary The find Command Questions xargs Terms Previous Section Next Section The expr Command The expr command performs simple integer arithmetic: $ expr 8 / 3 2 $ Notice that any fractional result is ignored. The general syntax is expr integer1 operand integer2 Possible operands are given in Table 18.3. Table 18.3 expr Operands Operand Description + Addition - Subtraction * Multiplication / Integer division (any fraction in the result is dropped) % Remainder from a division operation (also called the modulus function) Notice that the * sign must be quoted to prevent shell expansion (see Chapter 9), but the spaces around the * sign must not be quoted: $ expr 3 * 5 15 $ The remainder or modulus function is what remains after a division operation: $ expr 19 % 7 5
We recommend cheap and reliable webhost to host and run your web applications: Coldfusion Web Hosting services.

times to process all (Web hosting control panel) the standard input. xargs

Tuesday, October 30th, 2007

times to process all the standard input. xargs can be used to solve this problem: $ rm abc* rm: arg list too long The current directory contained too many filenames starting with abc, and the command buffer overflowed, so an error message was printed, and none of the files were deleted. xargs can solve this buffer overflow problem: ls | grep ‘^abc’ | xargs -n 20 rm Here you use grep (covered in Chapter 15, “Text Filters”) and regular expressions (covered in Chapter 16, “Filtering Text Using Regular Expressions”) to filter the output of ls passing only filenames that begin with abc. xargs allows rm to operate on those files and delete them, no matter how many there are. Sams Teach Yourself Shell Programming in 24 Hours Contents Index Hour 18: Miscellaneous Tools Previous Chapter Next Chapter Sections in this Chapter: The eval Command The expr Command The : Command The bc Command The type Command remsh/rsh/rcmd/remote (Remote Shell) The sleep Command Summary The find Command Questions xargs Terms Previous Section Next Section Copyright Macmillan Computer Publishing. All rights reserved.
Searching for affordable and proven webhost to host and run your servlet applications? Go to Linux Web Hosting services and you will find it.

Web design service - Sams Teach Yourself Shell Programming in 24 Hours

Monday, October 29th, 2007

Sams Teach Yourself Shell Programming in 24 Hours Contents Index Hour 18: Miscellaneous Tools Previous Chapter Next Chapter Sections in this Chapter: The eval Command The expr Command The : Command The bc Command The type Command remsh/rsh/rcmd/remote (Remote Shell) The sleep Command Summary The find Command Questions xargs Terms Previous Section Next Section xargs xargs is a command that accepts a list of words from standard input and provides those words as arguments to a given command: cat filelist | xargs rm You cannot pipe the output of cat directly to rm because rm does not look for filenames on standard input. xargs reads the files being passed by cat and builds up a command line beginning with rm and ending with the filenames. If there are a large number of files, xargs runs the rm command multiple times, deleting some of the files each time. You can specify how many arguments from standard input to build up on the command line with the -n option: cat filelist | xargs -n 20 rm -n 20 says to put only 20 arguments on each command line, so you delete only 20 files at a time. Here is a different example to give you more insight into how xargs works: $ ls acme report16 report3 report34 report527 $ ls | xargs -n 2 echo === === acme report16 === report3 report34 === report527 $ The first ls command shows us that there are only five files in the current directory. (These five can be regular files or directories; it does not matter for this example.) Next you pipe the output of ls to xargs, which composes and executes this command (the first of several): echo === acme report16 The command begins with echo === because these are the arguments given to the xargs command. The command then contains two filenames read from standard input. -n 2 tells xargs to add only two words from standard input to each echo command. I added === as the first echo argument so you can visually find the output from each separate echo command. You can see that xargs called echo three
You need excellent and relaible webhost company to host your web applications? Then pay a visit to Inexpensive Web Hosting services.

find / -name alpha -exec chmod a+r {} (My space web page)

Sunday, October 28th, 2007

find / -name alpha -exec chmod a+r {} ; Following -exec, you should specify a complete UNIX command and put {} where the filename will be inserted. Add ; at the end of the command to complete the required syntax. In the previous example, chmod runs on every file named alpha so that everyone can read the file. find / -name core -exec rm -f {} ; This example finds all files on the system named core and executes the rm command to delete them. The - f option to rm is specified so that rm does not ask for confirmation if you don’t own the file and don’t have write permission to the file. This is a useful command for root to run periodically because, if a process aborts, it might leave a debugging file named core in the current directory. After a while, these core files, which are not small, can collectively consume an unreasonable amount of disk space. This find command restores that disk space by finding and deleting those core files. Note - If you have thousands of files to process, xargs (covered in the next section) is more efficient than - exec. For example, find / -name core -print | xargs rm -f This command also deletes all core files much more quickly and with less overhead than the -exec option, which calls rm once for each file. Sams Teach Yourself Shell Programming in 24 Hours Contents Index Hour 18: Miscellaneous Tools Previous Chapter Next Chapter Sections in this Chapter: The eval Command The expr Command The : Command The bc Command The type Command remsh/rsh/rcmd/remote (Remote Shell) The sleep Command Summary The find Command Questions xargs Terms Previous Section Next Section Copyright Macmillan Computer Publishing. All rights reserved.
Note: If you are looking for cheap and reliable webhost to host and run your mysql application check mysql web server services.

find / -name alpha -size +50 -mtime (Cool web site) -3

Sunday, October 28th, 2007

find / -name alpha -size +50 -mtime -3 -print Here find displays files only when all the following are true: l The name is alpha l The size is greater than 50 blocks l The file was last modified fewer than 3 days ago You can specify a logical “or” condition using -o: find / ( -size +50 -o -mtime -3 ) -print Notice the use of the escaped parentheses to group the “either” and “or” options. This finds files that either have size greater than 50 blocks or were last modified fewer than 3 days ago. find: Negating Options You can use the ! sign to select files that do not match the given option: find /dev ! ( -type b -o -type c -o type d ) -print This locates all files in the /dev directory and its subdirectories that are not block special device files, character special device files, or directories. This is a useful command to locate device names that users have misspelled, which leaves a regular file in /dev that can waste a large amount of disk space. find: -print Action -print is an action that tells find to display the pathnames of all files that match the options given before - print. If you put the -print action before other options in the command line, those options are not used in the selection process: find / -size -20 -print -mtime +30 This command prints all files that contain fewer than 20 blocks. The -mtime option is ignored because it comes after the -print action on the command line. If no action is specified on the command line, -print is usually done by default. On older versions of UNIX, however, you must remember to include - print specifically, or no output is generated. find: -exec Action -exec is an action that lets you specify a UNIX command to run on each of the files that match the options given:
We recommend cheap and reliable webhost to host and run your web applications: Coldfusion Web Hosting services.

in the last 90 (Web and email hosting) days. There are three

Saturday, October 27th, 2007

in the last 90 days. There are three forms of date checking and each takes +n, n , or -n as an argument: -mtime Finds files last modified more than, exactly, or fewer than n days ago -atime Finds files last accessed more than, exactly, or fewer than n days ago -ctime Finds files whose inode was last changed more than, exactly, or fewer than n days ago. An inode is an entry in a disk table that contains information about a file such as its owner, size, and last access date. The inode is changed when the file is first created and also later if the owner, group, or permissions are changed. -atime Is Often Defeated by Nightly Backups In theory, find’s -atime option is useful if you are short of disk space and want to find files that have not been accessed in a long time so that you can archive them and delete them. However some backup programs, such as tar, prevent -atime from being useful because all files are accessed nightly during the system backup. cpio provides an -a option that remembers each file’s last access date and time and restores it after the file has been backed up so that find’s -atime option is still useful. find: -size Option The find -size option enables us to locate files based on the number of blocks in the file: find / -size +2000 -print This find command prints the names of all files that contain more than 2,000 blocks. It is useful when you want to find the largest files that are consuming disk space. Following -size, you must specify an integer number: +n Finds only files that contain more than n blocks n Finds only files that contain exactly n blocks -n Finds only files that contain fewer than n blocks Tip - It is a very rare occasion when you need to search for files that contain an exact number of blocks. Usually you look for files that contain more than n blocks or fewer than n blocks. UNIX neophytes often forget the plus or minus sign for these types of find options and then wonder why find did not locate the expected files. find: Combining Options If you specify more than one option, the file must match all options to be displayed:
We recommend cheap and reliable webhost to host and run your web applications: Coldfusion Web Hosting services.

Web hosting uk - find: -type Option The -type option enables us

Friday, October 26th, 2007

find: -type Option The -type option enables us to specify the type of file to search for, as in this example: find / -type d -print -type d indicates directories, so only files that are directories are displayed. In this example, all directories in the whole system are displayed. Notice that no -name option has been given, so you display all directories regardless of their names. Table 18.2 lists other types that are available. Table 18.2 Types Available for the find Command Type Description f Regular or normal file d Directory b Block special device file c Character special device file (raw) l Symbolic link p Named pipe find: -mtime, -atime, -ctime The find -mtime option enables us to locate files that were last modified recently or have not been modified in a long time: find / -mtime -5 -print -mtime takes an integer argument that is measured in days. This find command locates files that were last modified fewer than five days ago. This is a useful option when you are sure you modified a file recently but can’t remember its name or directory. Following -mtime you must specify an integer value: +n Find only files last modified more than n days ago n Find only files last modified exactly n days ago -n Find only files last modified fewer than n days ago To find files that have not been modified in the last n days, look for files that were last modified more than n days ago: find / -mtime +90 -print This shows all files that were last modified more than 90 days ago: that is, files that have not been modified
If you are searching for cheap webhost for your web application, please visit MySQL5 Web Hosting services.

Web hosting unlimited bandwidth - cd / find . -name alpha -print Sample

Thursday, October 25th, 2007

cd / find . -name alpha -print Sample output: ./reports/1998/alpha ./reports/1998/region2/alpha This point about relative versus absolute pathnames is important if you are using find to generate a list of files to be backed up. It is better to back up using relative pathnames that enable the files to be restored to a temporary directory. Some versions of UNIX let you search multiple directories with one find command: find dir1 dir2 -name alpha -print Refer to the man page about find on your UNIX system to see whether it enables multiple directories. find: -name Option The -name option enables us to specify either an exact or partial filename for find to match. find checks for a match only in the filename and not in the directory portion of the pathname. find / -name alpha -print /tmp/alpha has a matching filename and would be displayed by this command. /reports/alpha/file2 would not be displayed because find ignores the directory portion of the pathname. To specify a partial pathname, use filename substitution wildcards (refer to Chapter 8) . For instance, find / -name ‘*alpha*’ -print This displays all files that contain alpha anywhere within the filename. Here is some sample output: /reports/1998/alpha /reports/1998/alpha2 /reports/1998/old-alpha /reports/1998/region2/alpha /tmp/alpha /usr/fredp/ralphadams All the wildcards covered in Chapter 8 can be used: * ? [characters] [!characters] You must enclose the filename containing these wildcards within single quotes (see Chapter 9); otherwise, your find command does not always give you the desired results.
Note: In case you are looking for affordable and reliable webhost to host and run your j2ee application check Vision J2ee Web Hosting services.

Java web server - /reports/1998 The starting directory. find looks only in

Wednesday, October 24th, 2007

/reports/1998 The starting directory. find looks only in this directory and its subdirectories for files that match the following criteria. -name alpha An option that says you are looking only for files whose name is alpha– /reports/1998/region2/alpha, for example. find does not check any words in the directory portion of a filename for alpha. It checks only the filename itself, which is also called the file basename. -type f An option that says you are looking only for files of type f, which means regular or normal files, and not directories, device files, and so on. Any files selected must match both conditions: they must have the name alpha and they must be a regular file. -print An action that says to display to standard output the pathname for any files that match the criteria given by the options. -exec lp {} ; An action that says to use the lp command to print a hard copy of any files that match the criteria. Multiple actions can be specified. find: Starting Directory A UNIX system can contain a huge number of files, often so many that find can take several minutes or more to complete. For this reason, find enables specifying a starting directory to narrow down the number of files it has to search. Only files in this directory and all its subdirectories are checked. find enables either an absolute or relative pathname for the starting directory. If you specify an absolute pathname such as /reports, find /reports -name alpha -print then all the files found are specified as absolute pathnames, as in this sample output: /reports/1998/alpha /reports/1998/region2/alpha If you specify a relative pathname to find, cd /reports find ./1998 -name alpha -print all the files are displayed relative to the starting directory. For example, ./1998/alpha ./1998/region2/alpha To search the whole system, specify / as the starting directory. This indicates the system root directory that includes all other files and directories: find / -name alpha -print To search the entire system and still display all found files as relative pathnames, use the following:
If you are in need for chaep and reliable webhost to host your website, our recommendation is http web server services.

Sams Teach (Web hosting service) Yourself Shell Programming in 24 Hours

Monday, October 22nd, 2007

Sams Teach Yourself Shell Programming in 24 Hours Contents Index Hour 18: Miscellaneous Tools Previous Chapter Next Chapter Sections in this Chapter: The eval Command The expr Command The : Command The bc Command The type Command remsh/rsh/rcmd/remote (Remote Shell) The sleep Command Summary The find Command Questions xargs Terms Previous Section Next Section The find Command find: Starting Directory find: Combining Options find: -name Option find: Negating Options find: -type Option find: -print Action find: -mtime, -atime, -ctime find: -exec Action find: -size Option The find command is a very powerful, very flexible way to create a list of files that match given criteria. The basic syntax is find start-dir options actions Here is a simple find example: find / -name alpha -print This example looks for all files named alpha and displays the full pathname to the screen (standard output). It is a useful command to know about when you are sure you have a file named alpha but can’t remember what directory it is in or want to know whether it exists in more than one directory. Here is some possible output from that command: /reports/1998/alpha /reports/1998/region2/alpha /tmp/alpha I will shortly cover the elements of the find command in detail. Files can be selected not only by name but also by size, last modification date, last access date, and so on. First let me give you a more complex example with a brief explanation of each part of the example, so you get a sense of what options and actions look like: find /reports/1998 -name alpha -type f -print -exec lp {} ; Table 18.1 provides a breakdown of these elements. Table 18.1 A Sample find Command Command Element Description
In case you need quality webspace to host and run your web applications, try our personal web hosting services.