Introduction
In VLSI verification and RTL design, file management is a daily task — moving testbenches, creating backups, cleaning log files, or searching through massive simulation outputs.
This tutorial covers essential Linux commands to copy, move, delete, and search files efficiently.
1. Copying Files and Directories – cp
To make a copy of a file:
cp file1 file2Example:
cp science.txt backup.txtThis creates a new file named backup.txt with the same content as science.txt.
To copy directories recursively (including subfolders):
cp -R dir1 dir2💡 Example:
cp -R rtl backup_rtl — copies your RTL folder with all files.
2. Moving and Renaming Files – mv
Move or rename files:
mv file1 file2If file2 doesn’t exist → it renames the file.
If file2 is a directory → it moves the file inside that directory.
Examples:
mv science.txt ~/unixstuff/backups/mv report.log old_report.log📘 Use Case: Renaming simulation logs after each run (e.g., sim_v1.log → sim_final.log).
3. Removing Files and Directories – rm, rmdir
To delete a file:
rm filenameTo remove an empty directory:
rmdir dirnameTo delete a directory and all its contents (use with care):
rm -r dirname⚠️ Caution: There is no recycle bin in Linux. Once deleted, it’s gone.
4. Displaying File Contents
cat
Display the entire file:
cat science.txtless
View a file page-by-page (recommended for long logs):
less science.txtUse:
- Space → next page
- q → quit
head
View the first 10 lines (default):
head science.txtTo see 5 lines:
head -5 science.txttail
View the last 10 lines:
tail science.txtTo view last 15 lines:
tail -15 science.txt💡 EDA Tip: Use tail -f sim.log to monitor a simulation log live while running.
5. Searching Inside Files – grep
Search for a keyword:
grep science science.txtIgnore case:
grep -i science science.txtCount matching lines:
grep -c science science.txtShow non-matching lines:
grep -v science science.txtHighlight matches:
grep --color -i "error" sim.log💡 Real-World Example: Quickly locate simulation errors:
grep --color -i "uvm_error" sim.log6. Counting Words, Lines, and Characters – wc
| Command | Description |
| wc -l file | Count lines |
| wc -w file | Count words |
| wc -m file | Count characters |
Example:
wc -l sim.logThis tells you how long your log file is — handy when checking if the simulation completed fully.
Summary Table
| Command | Description |
| cp file1 file2 | Copy file1 to file2 |
| cp -R dir1 dir2 | Copy entire directory |
| mv file1 file2 | Move or rename file |
| rm file | Remove a file |
| rmdir dir | Remove empty directory |
| rm -r dir | Remove directory recursively |
| cat file | Display file content |
| less file | View file page by page |
| head file | Show first few lines |
| tail file | Show last few lines |
| grep keyword file | Search keyword inside file |
| wc file | Count words, lines, characters |
Practice Tasks
- Copy a file named pcie_tlp.sv into a backup directory using cp.
- Rename it as pcie_tlp_v2.sv using mv.
- Delete any temporary directory with rm -r tempdir.
- Search for “UVM_ERROR” in your simulation log with grep –color.
- Count the total number of transactions logged using wc -l txn_log.txt.
Real-World Scenario
When debugging simulations:
- Use grep -i error *.log to find failing runs.
- Use tail -f vcs.log to track progress live.
- Use cp and mv to organize multiple test iterations neatly.
These simple commands can save hours during regression analysis.
