solikid.blogg.se

Grep cheat sheet
Grep cheat sheet








grep cheat sheet

name 'filename.rb' -print # locate a file locate # see command history history # search CLI history -R File contents # -B/A = show 2 lines before/after search_term grep -B 2 -A 2 search_term # - shows both before and after grep -2 search_term # Search on all files in directory (recursively) grep -r search_term # search through *.gz files is the same except with zgrep zgrep search_term # Fast grep printing lines containing a string pattern fgrep -R string_pattern CLI # View command history history # Run last command that started with 'his' (3 letters min) !his # Search through command history -R # Execute last command with sudo sudo !! Managing resources Memory, Disk, & CPU usage # disk space info. System Commands Distribution Information # Debian/Ubuntu uname -a lsb_release -a # CentOS/RedHat cat /etc/centos-release cat /etc/redhat-release # This will provide a lot more information cat /etc/os-release Shut down or Reboot shutdown -h now reboot Permissions # change the user:group ownership of a file/dir chown root:git # make a file executable chmod u+x Files and directories # create a new directory and all subdirectories mkdir -p dir/dir2/dir3 # Send a command's output to file.txt, no STDOUT ls > file.txt # Send a command's output to file.txt AND see it in STDOUT ls | tee /tmp/file.txt # Search and Replace within a file sed -i 's/original-text/new-text/g' See all set environment variables env Searching File names # search for a file in a filesystem find. Contributions are welcome to help add them. Most of the commands below have not been labeled as to which distribution they work If you are a GitLab Support Engineer, consider this a cross-reference to

grep cheat sheet

If you are administering GitLab you are expected to know these commands for your distribution Having an issue with GitLab, you may want to check your support optionsįirst, before attempting to use this information. It is listed here for transparency,Īnd it may be useful for users with experience with Linux.

grep cheat sheet

(?#find) (?P\b.+ ), (?P\b.This is the GitLab Support Team's collection of information regarding Linux, that they Groups can be named (assume a file of lastname, firstname altered using "preg_replace()") disallow digit AND whitespace occurrences - ? * + rest of phone number means not digit OR whitespace, both match \s whitespace (space, tab, vtab, newline) \W, \D, or \S, (NOT word, digit, or whitespace) ) shorthand classes \w "word" character (letter, digit, or underscore) \d digit gr y match gray or grey match any letter or digit (In always escape. Use \ to search for these special characters:Ĭ: \\windows matches c:\windows alternatives - | (OR) cat|dog match cat or dog order matters if short alternative is part of longer id|identity matches id or identityĪs soon as 1st alternative matches identity|id matches id or identity order longer to shorter when alternatives overlap (To match whole words, see scope and groups.) character classes - or match any vowel match a NON vowel r ng match ring, w rangle, sp rung, etc. REGEX Cheat Sheet GREP cheat sheet characters - what to seek ring matches ring, sp ringboard, ringtone, etc.










Grep cheat sheet