cmd |
desc |
. |
Run a command script in the current shell |
!! |
Run the last command again |
### |
Comment / Remark |
cmd < file |
Input of cmd from file |
cmd1 <(cmd2) |
Output of cmd2 as file input to cmd1 |
cmd > /dev/null |
Discard stdout of cmd |
cmd &> file |
Every output of cmd to file |
cmd1 |
cmd2 |
cmd1 |
& cmd2 |
cmd1 ; cmd2 |
Run cmd1 then cmd2 |
cmd1 && cmd2 |
Run cmd2 if cmd1 is successful |
cmd1 |
|
cmd |
desc |
alias |
Create an alias • |
apropos |
Search Help manual pages (man -k) |
apt-get |
Search for and install software packages |
aptitude |
Search for and install software packages |
aspell |
Spell Checker |
awk |
Find and Replace text, db sort/validate/index awk
|
cmd |
desc |
basename |
Strip directory and suffix from filenames |
bc |
Arbitrary precision calculator language |
bg |
Send to background |
break |
Exit from a loop • |
builtin |
Run a shell builtin |
bzip2 |
Compress or decompresss named file(s) |
cmd |
desc |
cal |
Display a calendar |
case |
Conditionally perform a command |
cat |
Concatenate and print (display) the content of files |
cd |
Change Directory |
cfdisk |
Partition table manipulator for Linux |
chgrp |
Change group ownership |
chmod |
Change access permissions |
chown |
Change file owner and group |
chroot |
Run a command with a different root directory |
chkconfig |
System services (runlevel) |
cksum |
Print CRC checksum and byte counts |
clear |
Clear terminal screen |
cmp |
Compare two files |
comm |
Compare two sorted files line by line |
command |
Run a command - ignoring shell functions • |
continue |
Resume the next iteration of a loop • |
cp |
Copy one or more files to another location |
cron |
Daemon to execute scheduled commands |
crontab |
Schedule a command to run at a later time |
csplit |
Split a file into context-determined pieces |
cut |
Divide a file into several parts |
cmd |
desc |
date |
Display or change the date & time |
dc |
Desk Calculator |
dd |
disk dump,write disk headers, boot records |
ddrescue |
Data recovery tool |
declare |
Declare variables and give them attributes • |
df |
Display free disk space |
diff |
Display the differences between two files |
diff3 |
Show differences among three files |
dig |
DNS lookup |
dir |
Briefly list directory contents |
dircolors |
Colour setup for `ls' |
dirname |
Convert a full pathname to just a path |
dirs |
Display list of remembered directories |
dmesg |
Print kernel & driver messages |
du |
Estimate file space usage |
cmd |
desc |
echo |
Display message on screen • |
egrep |
Search file(s) for match to extended expression |
eject |
Eject removable media |
enable |
Enable and disable builtin shell commands • |
env |
Environment variables |
ethtool |
Ethernet card settings |
eval |
Evaluate several commands/arguments |
exec |
Execute a command |
exit |
Exit the shell |
expect |
Automate applications accessed over a terminal |
expand |
Convert tabs to spaces |
export |
Set an environment variable |
expr |
Evaluate expressions |
cmd |
desc |
false |
Do nothing, unsuccessfully |
fdformat |
Low-level format a floppy disk |
fdisk |
Partition table manipulator for Linux |
fg |
Send job to foreground |
fgrep |
Search file(s) for lines that match a fixed string |
file |
Determine file type |
find |
Search for files that meet a desired criteria |
fmt |
Reformat paragraph text |
fold |
Wrap text to fit a specified width. |
for |
Expand words, and execute commands |
format |
Format disks or tapes |
free |
Display memory usage |
fsck |
File system consistency check and repair |
ftp |
File Transfer Protocol |
function |
Define Function Macros |
fuser |
Identify/kill the process that is accessing a file |
cmd |
desc |
gawk |
Find and Replace text within file(s) |
getopts |
Parse positional parameters |
grep |
Search file(s) for lines that match a given pattern |
groupadd |
Add a user security group |
groupdel |
Delete a group |
groupmod |
Modify a group |
groups |
Print group names a user is in |
gzip |
Compress or decompress named file(s) |
cmd |
desc |
hash |
Remember full pathname of a name argument |
head |
Output the first part of file(s) |
help |
Display help for a built-in command • |
history |
Command History |
hostname |
Print or set system name |
htop |
Interactive process viewer |
cmd |
desc |
iconv |
Convert the character set of a file |
id |
Print user and group id's |
if |
Conditionally perform a command |
ifconfig |
Configure a network interface |
ifdown |
Stop a network interface |
ifup |
Start a network interface up |
import |
Capture an X server screen and save to file |
install |
Copy files and set attributes |
ip |
Routing, devices and tunnels |
cmd |
desc |
jobs |
List active jobs • |
join |
Join lines on a common field |
cmd |
desc |
kill |
Kill a process by specifying its PID |
killall |
Kill processes by name |
cmd |
desc |
less |
Display output one screen at a time |
let |
Perform arithmetic on shell variables • |
link |
Create a link to a file |
ln |
Create a symbolic link to a file |
local |
Create variables • |
locate |
Find files |
logname |
Print current login name |
logout |
Exit a login shell • |
look |
Display lines beginning with a given string |
lpc |
Line printer control program |
lpr |
Off line print |
lprint |
Print a file |
lprintd |
Abort a print job |
lprintq |
List the print queue |
lprm |
Remove jobs from the print queue |
ls |
List information about file(s) |
lsof |
List open files |
cmd |
desc |
make |
Recompile a group of programs |
man |
Help manual |
mkdir |
Create new folder(s) |
mkfifo |
Make FIFOs (named pipes) |
mkisofs |
Create an hybrid ISO9660/JOLIET etc |
mknod |
Make block or character special files |
more |
Display output one screen at a time |
most |
Browse or page through a text file |
mount |
Mount a file system |
mtools |
Manipulate MS-DOS files |
mtr |
Network diagnostics (traceroute/ping) |
mv |
Move or rename files or directories |
mmv |
Mass Move and rename (files) |
cmd |
desc |
netstat |
Networking information |
nice |
Set the priority of a command or job |
nl |
Number lines and write files |
nohup |
Run a command immune to hangups |
notify-send |
Send desktop notifications |
nslookup Query |
Internet name servers interactively |
cmd |
desc |
open |
Open a file in its default application |
op |
Operator access |
cmd |
desc |
passwd |
Modify a user password |
paste |
Merge lines of files |
pathchk |
Check file name portability |
ping |
Test a network connection |
pkill |
Kill processes by a full or partial name. |
popd |
Restore previous value of the current directory |
pr |
Prepare files for printing |
printcap |
Printer capability database |
printenv |
Print environment variables |
printf |
Format and print data • |
ps |
Process status |
pushd |
Save and then change the current directory |
pv |
Monitor the progress of data through a pipe |
pwd |
Print Working Directory |
cmd |
desc |
quota |
Display disk usage and limits |
quotacheck |
Scan a file system for disk usage |
quotactl |
Set disk quotas |
cmd |
desc |
ram |
ram disk device |
rar |
Archive files with compression |
rcp |
Copy files between two machines |
read |
Read a line from standard input • |
readarray |
Read from stdin into an array variable • |
readonly |
Mark variables/functions as readonly |
reboot |
Reboot the system |
rename |
Rename files |
renice |
Alter priority of running processes |
remsync |
Synchronize remote files via email |
return |
Exit a shell function |
rev |
Reverse lines of a file |
rm |
Remove files |
rmdir |
Remove folder(s) |
rsync |
Remote file copy (Synchronize file trees) |
cmd |
desc |
screen |
Multiplex terminal, run remote shells via ssh |
scp |
Secure copy (remote file copy) |
sdiff |
Merge two files interactively |
sed |
Stream Editor |
select |
Accept keyboard input |
seq |
Print numeric sequences |
set |
Manipulate shell variables and functions |
sftp |
Secure File Transfer Program |
shift |
Shift positional parameters |
shopt |
Shell Options |
shutdown |
Shutdown or restart linux |
sleep |
Delay for a specified time |
slocate |
Find files |
sort |
Sort text files |
source |
Run commands from a file '.' |
split |
Split a file into fixed-size pieces |
ssh |
Secure Shell client (remote login program) |
stat |
Display file or file system status |
strace |
Trace system calls and signals |
su |
Substitute user identity |
sudo |
Execute a command as another user |
sum |
Print a checksum for a file |
suspend |
Suspend execution of this shell • |
sync |
Synchronize data on disk with memory |
cmd |
desc |
tail |
Output the last part of file |
tar |
Store, list or extract files in an archive |
tee |
Redirect output to multiple files |
test |
Evaluate a conditional expression |
time |
Measure Program running time |
timeout |
Run a command with a time limit |
times |
User and system times |
touch |
Change file timestamps |
top |
List processes running on the system |
tput |
Set terminal-dependent capabilities, color, position |
traceroute |
Trace Route to Host |
trap |
Run a command when a signal is set(bourne) |
tr |
Translate, squeeze, and/or delete characters |
true |
Do nothing, successfully |
tsort |
Topological sort |
tty |
Print filename of terminal on stdin |
type |
Describe a command • |
cmd |
desc |
ulimit |
Limit user resources • |
umask |
Users file creation mask |
umount |
Unmount a device |
unalias |
Remove an alias • |
uname |
Print system information |
unexpand |
Convert spaces to tabs |
uniq |
Uniquify files |
units |
Convert units from one scale to another |
unrar |
Extract files from a rar archive |
unset |
Remove variable or function names |
unshar |
Unpack shell archive scripts |
until |
Execute commands (until error) |
uptime |
Show uptime |
useradd |
Create new user account |
userdel |
Delete a user account |
usermod |
Modify user account |
users |
List users currently logged in |
uuencode |
Encode a binary file |
uudecode |
Decode a file created by uuencode |
cmd |
desc |
v |
Verbosely list directory contents (`ls -l -b') |
vdir |
Verbosely list directory contents (`ls -l -b') |
vi |
Text Editor |
vmstat |
Report virtual memory statistics |
cmd |
desc |
wait |
Wait for a process to complete • |
watch |
Execute/display a program periodically |
wc |
Print byte, word, and line counts |
whereis |
Search user's locations files for a program |
which |
Search the user's $path for a program file |
while |
Execute commands |
who |
Print all usernames currently logged in |
whoami |
Print the current user id and name (`id -un') |
wget |
Retrieve web pages or files via HTTP, HTTPS or FTP |
write |
Send a message to another user |
cmd |
desc |
xargs |
Execute utility, pass constructed argument list(s) |
xdg-open |
Open a file/URL in user's preferred application. |
cmd |
desc |
yes |
Print a string until interrupted |
cmd |
desc |
zip |
Package and compress (archive) files. |
NB "" used to contine bash command on next line
awk 'program' file to parse e.g.
ex 1 print the first record where the file is delimeted by a single space and the fist record does not contain "e"
awk 'BEGIN {FS=" "} $1 !~ /e/ {print $1}' Documents/somedata.txt
can have a BEGIN and END section where actions are completed before and after the inputed data or file e.g.
awk 'BEGIN {FS=" "; print "FILE START";} $1 !~ /e/ {print $1;} \
END { print "FILE END";}' Documents/somedata.txt
use of if
awk 'BEGIN {FS=" "; print "FILE START"} {if ($1 == "ping") {print "YES > "$1} \
else {print "NO > "$1} } END { print "FILE END"}' Documents/somedata.txt
functions
awk 'function n(v) { x = length(v); return x } ; \
BEGIN { FS=" "; print "FILE START";} {print n($1)":"$1;} \
END { print "FILE END"}' documents/writelog.bat
variables and for loops
awk 'myVar = 2; { for ( i = 0; i < 5; i++) { print myVar i ; myVar++; } }'
some bult in functions
{ gsub(/Britain/, "United Kingdom"); print } # global sub via regex
{ print length(x) ;} # len of string
split("cul-de-sac", a, "-", seps) # puts split items in array a[n] "-" into array seps[n]
sub(/at/, "ith", str) # one sub
substr(string, 3, 3) # substring
Sample AWK program to make SQL inset from delimetered file.
# AWK PROGRAM TO CONVERT | DELIMITED FILE TO SQL INSERT STATEMENTS
##################################################################
# strings are trimmed and values have commas removed plus dates are reformated
# Main Functions
################
function nullStr(a) { if(trim(a) == "") b="NULL";else b="'"clean(trim(a))"'"; return b } # rtn NULL or trimStr
function nullVal(a) { if(trim(a) == "" || length(trim(a)) == 0 ) b="NULL";else b=remComma(trim(a)); return b } # rtn NULL or trimVal
function sqlDate(a) { if(trim(a) == "") b="NULL";else b="'"substr(a,7,4)"-"substr(a,4,2)"-"substr(a,1,2)"'"; return b } # rtn NULL or reform date
# Sub Functions
###############
function clean(s) { gsub(/'/, " ", s); return s } #
function ltrim(s) { sub(/^[ \s\t\r\n]+/, "", s); return s } # left trims s
function rtrim(s) { sub(/[ \s\t\r\n]+$/, "", s); return s } # right trims s
function trim(s) { return rtrim(ltrim(s)); } # whole trim s
function remComma(s) { gsub(/,/,"",s); if(s ~ /-/) {sub(/-/,"",s);return "-"s;} else return s ;} # removes commas
# Main Program Converts Data to SQL Clear and Insert file
#########################################################
BEGIN {FS="|"; print "USE <DB_NAME>;\nGO\nDELETE FROM [<TABLE_NAME>];\n"} # FS = Field Separator NB RS is Record Separator
#START File Process
###################
/^\|\s|\|[0-9]/ {print "BEGIN TRY" # For Any Line that starts "| " OR "|" then a number Begin Try is an SQL statement
print "INSERT INTO [<TABLE_NAME>] ";
print "( " ;
print "[<fieldName1>],[<fieldName2>],....[<fieldName(n)>],updated"; # where updated is a timestamp field
print ") VALUES (";
print nullStr( $3)","nullVal( $4)","sqlDate($15)",.....,'"strftime("%Y-%m-%d %H:%M:%S",systime())"'"; # Note calc of updated
print ") END TRY"; # End Try is an SQL statement
print "BEGIN CATCH"; # Begin Catch is an SQL statement
print "print 'error'"; # print 'error' is an SQL statement
print "END CATCH"; # End Catch is an SQL statement
}
To run on its own use:
awk.exe
awktestprg.txt
awktestrpt.txt
msys-2.0.dll
msys-gcc_s-seh-1.dll
msys-gmp-10.dll
msys-iconv-2.dll
msys-intl-8.dll
msys-mpfr-4.dll
msys-ncursesw6.dll
msys-readline7.dll