fertstate.blogg.se

Grep count
Grep count








grep count

type f -print0 | xargs -0 du -h | sort -hr | head -20 Perform Action for Every File in a Directory Files older than 30 days are deleted.Įcho "Send this to log" > $LOG_FILE 2>&1įind /tmp/backup*.log -mtime +30 -delete Find Big Filesįind the top 20 biggest files recursively from this directory. The log file includes the date in the file name.

grep count

#Grep count how to#

The following script provides an example of how to manage a log rotation using the Bash shell. See the previous section for another variant on log rotation. This is one example of a log rotation, where the most current log doesn't include the date in it's name. Mv /tmp/backup.log /tmp/backup-$DATE_SUFFIX.logįind /tmp/backup*.log -mtime +30 -delete In the following script aīackup log is renamed if it is present and files older than 30 days are deleted are deleted. The Bash shell allows you to check for the presence of a file using the "" comparison. # kill -9 `ps -ef | grep ora | awk ' \ įind /backup/logs/daily_backup* -mtime +5 -delete File Exists Check You can kill multiple processes using a single command by combining "kill" with the "ps" and "awk" commands. Specific processes can be killed by specifying the process id in the kill command. The "ps" command lists current process information. See Linux Process Management (ps, top, renice, kill).

  • The "wc -l" command returns the number of lines from "who", and hence the number of connected users.
  • The "grep -i ora" command restricts the output to lines containing "ora".
  • The "tail -5" command restricts the output to the last 5 lines of the who command.
  • The "head -5" command restricts the output to the first 5 lines of the who command.
  • grep count

    The "who" command can be used to list all users who have OS connections. The "passwd" command is used to set, or reset, the users login password. The "-r" flag removes the default directory. The "userdel" command is used to delete existing users. The "usermod" command is used to modify the user settings after a user has been created. The "-s" flag specifies the default shell.The "-m" flag creates the default directory.The "-d" flag specifies the default directory.The "-g" flag specifies the secondary group.The "-G" flag specifies the primary group.

    grep count

    Root> useradd -G oinstall -g dba -d /usr/users/my_user -m -s /bin/ksh my_user The "useradd" command is used to add OS users. The "-R" flag causes the command ro recurse through any subdirectories. The "chown" command is used to reset the ownership of files after creation. The "chmod" command is used to alter file permissions after the file has been created.ħ (u+rwx) 7 (g+rwx) 7 (o+rwx) read + write + executeĥ (u+rx) 5 (g+rx) 5 (o+rx) read + executeĬharacter eqivalents can be used in the chmod command. The umask value is subtracted from the default permissions (666) to give the final permission. The "umask" command can be used to read or set default file permissions for the current user. See Linux Files, Directories and Permissions. The "which" command searches your PATH setting for occurrences of the specified executable. The "which" command can be used to find the location of an executable you are using. Wildcards such as "dbms*" can be used for the filename. The "/" flag represents the staring directory for the search. Root> find / -print | grep -i dbmspool.sql The "find" command can be used to find the location of specific files. The "rmdir" command is used to delete directories. The "mkdir" command is used to create new directories. The "cp" command is used to copy files and directories. The "." represents the current directory. The "mv" command is used to move or rename files and directories. The "-R" flag tells the command to recurse through subdirectories. The "rm" command is used to delete files and directories. The "touch" command is used to create a new empty file with the default permissions. The "cd" command is used to change directories. If no location is defined it acts on the current directory. The "ls" command lists all files and directories in the specified directory. The "pwd" command displays the current directory. Perform Action for Every Line in a File.Perform Action for Every File in a Directory.Over time I've been adding more Linux-related entries. This article contains a brief list of commands that most UNIX DBAs will need on a regular basis. Home » Articles » Misc » Here UNIX Commands For DBAs










    Grep count