Redirection
Redirection is used to manipulate input and output of commands
Standard input
to sort content of text file
sort < /etc/services
Standard output
to create a new file that contains output of command
ls > myfile.txt
to append result to file that contains output of command
who >> myfile.txt
Standard error
to avoid standard errors output during command execution
grep -i 'abc' content 2>/dev/null
Piping
A pipe is used to send output of one command to be used as input for a second command
to filter results
ps aux | grep http
to output results to a file and send them as an input to other commant tee is used
ps aux | tee textfile | grep ssh
History
All user commands are written to file ~/.bash_history (~/.sh_history for AIX)
To see the list of commands from history
history
To clear history
history -w
To repeat command from history with id nn
!nn
Variables
Variables are convenient for scripting
To see default environments variables
env
To define variable
varname=value
To read variable
echo $varname
Shortcuts
Bash Shortcut | Description |
Ctrl+l | (smal (L) clear screen |
Ctrl+u | wipe current command line |
Ctrl+a | move to the beginning of a line |
Ctrl+e | move to the endof a line |
Ctrl+c | interrupt the current process |
Ctrl+d | exit |
Aliases
To use short link to a command an alias functin could be used
alias p="cd ~/787/test"
Config files
- Global
- /etc/environment contains a list of variables that is processed while starting bash
- User specific
- /etc/.profile.d additional user-specific configuration
- ~/.bash_profile execute at the beginning of session
- ~/.bash_logout execute at the logout
- Subshell configuration
- ~/.bashrc for each new subshell
Page last modified on August 09, 2021, at 02:45 PM
Powered by
PmWiki