我编写了一个Bash脚本,用于打开以参数形式传递的文件并将其写入另一个文件。但是,如果文件不在当前目录中,我的脚本只能正常工作。现在我需要打开并写入不在当前目录中的文件。
如果我的脚本名为"compile",那么"
如果我的脚本名为"compile",那么"
./compile next/123/file.txt
"应该打开传递路径中的file.txt
。我该怎么办?#!/bin/sh
#FIRST SCRIPT
clear
echo "-----STARTING COMPILATION-----"
#echo $1
name=$1 # Copy the filename to name
find . -iname $name -maxdepth 1 -exec cp {} $name \;
new_file="tempwithfile.adb"
cp $name $new_file #copy the file to new_file
echo "compiling"
dir >filelist.txt
gcc writefile.c
run_file="run_file.txt"
echo $name > $run_file
./a.out
echo ""
echo "cleaning"
echo ""
make clean
make -f makefile
./semantizer -da <withfile.adb