| |
1,准备好3个文件
(1)compare.sh
(2)gdsA.pipo (summery文件中,layer部分)
(3)gdsB.pipo (summery文件中,layer部分)
2,打开terminal,键入
./compare.sh ./gdsA.pipo ./gdsB.pipo
3,生成比较页面,可查看哪些layer出现了变动
附,compare.sh:
#!/bin/bash
# Script Name: compare_sorted_first4cols.sh
# Description: Extract first 4 columns from two text files, sort them, save sorted files, and compare using vimdiff
# Usage: ./compare_sorted_first4cols.sh file1.txt file2.txt
# Check if exactly two arguments are provided
if [ $# -ne 2 ]; then
echo "Error: Exactly two filenames are required as arguments"
echo "Usage: $0 file1.txt file2.txt"
exit 1
fi
# Get input filenames
FILE1="$1"
FILE2="$2"
# Check if files exist
if [ ! -f "$FILE1" ]; then
echo "Error: File '$FILE1' does not exist"
exit 1
fi
if [ ! -f "$FILE2" ]; then
echo "Error: File '$FILE2' does not exist"
exit 1
fi
# Create temporary files
TMP1=$(mktemp /tmp/file1_cols.XXXXXX)
TMP2=$(mktemp /tmp/file2_cols.XXXXXX)
# Extract first 4 columns to temporary files
echo "Extracting first 4 columns from $FILE1..."
awk '{print $1, $2, $3, $4}' "$FILE1" > "$TMP1"
echo "Extracting first 4 columns from $FILE2..."
awk '{print $1, $2, $3, $4}' "$FILE2" > "$TMP2"
# Create sorted output filenames in current directory
SORTED1="$(basename "$FILE1" .txt)_sorted_first4.txt"
SORTED2="$(basename "$FILE2" .txt)_sorted_first4.txt"
# Sort the extracted columns and save to current directory
echo "Sorting extracted columns and saving to current directory..."
sort "$TMP1" > "$SORTED1"
sort "$TMP2" > "$SORTED2"
echo "Sorted files created:"
echo " - $SORTED1"
echo " - $SORTED2"
echo "Comparing sorted results using vimdiff..."
echo "Press ESC and then type :qa to exit vimdiff"
# Compare using vimdiff
vimdiff "$SORTED1" "$SORTED2"
# Clean up temporary files
rm -f "$TMP1" "$TMP2"
echo "Comparison completed, temporary files removed"
echo "Sorted files preserved in current directory: $SORTED1, $SORTED2"