Frequently-Used System Commands in a Command Shell

DESCRIPTION   MS Windows   Linux and MacOS
         
Files        
List files in current working directory   dir   ls
Pattern match to list certain files   dir *.txt   ls *.txt
Display contents of a text file   type filename   cat filename
Copy a file   copy sourcename targetname   cp sourcename targetname
Move a file   move filename directoryName   mv filename directoryName/.
Rename a file   rename oldname newname   mv oldname newname
Delete a file   del filename   rm filename
         
Directories        
Change drive letter (to C)   C:   N/A
Show current working directory   cd   pwd
Change to a subdirectory   cd directoryName   cd directoryName
Change to the parent directory   cd ..   cd ..
Change to the root directory   cd c:\   cd /
Change to a certain directory   cd c:\dirA\dirB   cd /dirA/dirB
Change to your home directory   N/A   cd
Change to a subdirectory of home   N/A   cd ~/directoryName
Create a subdirectory   mkdir directoryName   mkdir directoryName
Remove an empty subdirectory   rd directoryname   rmdir directoryName
         
G++ Compiler        
Compile and link a C++ file   g++ -Wall myProgram.cpp   g++ -Wall myProgram.cpp
Compile and link a C++ file (Renaming the executable file)   g++ -Wall myProgram.cpp -o myProgram.exe   g++ -Wall myProgram.cpp -o myProgram
Only compile a C++ file (no link)   g++ -Wall -c myProgram.cpp   g++ -Wall -c myProgram.cpp
Run an executable file (default name)   a.exe   a.out
Run an executable file (renamed)   myProgram.exe   myProgram
         
Redirection of stdin (cin) and stdout (cout) File Streams        
Redirect the standard input file   a.exe <datafile.txt   a.out <datafile
Redirect the standard output file   a.exe >reportfile.txt   a.out >reportfile
Redirect both stdin and stdout   a.exe <datafile.txt >reportfile.txt   a.out <datafile >reportfile
Pipe stdout into stdin   a.exe | myProgram.exe   a.out | myProgram