Certainly! Using the Command Prompt or Terminal to execute commands can be very powerful. Here are some additional useful tricks and commands for both Windows and macOS:
### **Windows Command Prompt Tricks:**
1. **Open All Files of a Certain Type:**
```shell
start *.txt
```
Opens all `.txt` files in the current directory. Replace `.txt` with any other file extension to open different types of files.
2. **Open a Specific File with a Specific Application:**
```shell
start winword "example.docx"
```
Opens `example.docx` in Microsoft Word specifically. Replace `winword` with the executable name of the application you want to use.
3. **Open Multiple Files with Different Extensions:**
```shell
start file1.docx file2.docx file3.docx
```
Opens `file1.docx`, `file2.docx`, and `file3.docx` if they are in the current directory.
4. **Run a Program with Arguments:**
```shell
"C:\Path\To\Program.exe" /arg1 /arg2
```
Run a program with specific arguments. Ensure the path is in quotes if it contains spaces.
5. **List Files in a Directory:**
```shell
dir
```
Lists all files and directories in the current directory. Use `dir /s` to list files in all subdirectories.
6. **Copy Files to Another Directory:**
```shell
copy *.docx D:\Backup
```
Copies all `.docx` files from the current directory to `D:\Backup`.
7. **Delete Files:**
```shell
del *.tmp
```
Deletes all `.tmp` files in the current directory. Be cautious with this command!
### **macOS Terminal Tricks:**
1. **Open All Files of a Certain Type:**
```shell
open *.pdf
```
Opens all `.pdf` files in the current directory. Change `.pdf` to the desired file extension.
2. **Open a Specific File with a Specific Application:**
```shell
open -a "Microsoft Word" example.docx
```
Opens `example.docx` with Microsoft Word. Replace `"Microsoft Word"` with any application name.
3. **Open Multiple Files:**
```shell
open file1.docx file2.docx file3.docx
```
Opens `file1.docx`, `file2.docx`, and `file3.docx` in their default applications.
4. **Run a Script or Program:**
```shell
./script.sh
```
Executes a shell script in the current directory. Ensure the script has executable permissions (`chmod +x script.sh`).
5. **List Files in a Directory:**
```shell
ls
```
Lists files and directories in the current directory. Use `ls -l` for detailed information.
6. **Copy Files to Another Directory:**
```shell
cp *.txt /path/to/destination/
```
Copies all `.txt` files from the current directory to the specified path.
7. **Delete Files:**
```shell
rm *.tmp
```
Deletes all `.tmp` files in the current directory. Use `rm -rf` for directories, but be very careful with this command!
These commands and tricks should help you work more efficiently with files and applications using the command line on both Windows and macOS.
Comments
Post a Comment