25-06-2016, 09:57
|
|
|
חבר מתאריך: 11.07.05
הודעות: 1,029
|
|
לינוקס (אובונטו)- סקיפרט שמקמפל את כל קבצי ה c במיקום מסויים
קיבלתי תרגיל בו אני אני צריך ליצור סקריפט שמקבל כקלט ($1) את הנתיב בו נמצאים קבצי הקוד (c), מקמפל אותם ושומר את קבצי ההרצה בתוך תיקייה חדשה באותו נתיב (למשל תיקייה בשם compiled_file).
הסתבכתי עם כמה דברים, נסיתי לעשות ככה:
קוד:
ls $1 *.c | while read F; do gcc -B $1 -Wall -o `e| cut -d . -f 1 - ` $F; done
קודם כל פקודת הls נותנת שגיאה שהיא לא מוצאת קבצי c בנתיב למרות שיש שם, אני לא יודע איך לשלב את ה*.c ואת הנתיב הרצוי בתוך הפקודה.
בנוסף, גם הgcc צועק לי שהוא לא מוצא את קבצי הc למרות שנתתי לו נתיב בפקודה -B. אני כנראה לא יודע את התחביר לכתיבת ארגומנט קלט כנתיב ובנוסף ארגומנטים רגילים של הפקודה.
דבר נוסף, הבנתי שדרך הקלט-o בgcc אוכל לשמור את קבצי הפלט בתיקייה אבל איך עושים זאת?
אני צריך להימנע משגיאות של אין הרשאה וכו'
הפלט בנתיים:
קוד:
ls: cannot access '*.c': No such file or directory ./DirCompile.sh: line 1: e: command not found
gcc: fatal error: no input files compilation terminated. ./DirCompile.sh: line 1: e: command not found
gcc: fatal error: no input files compilation terminated. ./DirCompile.sh: line 1: e: command not found
gcc: fatal error: no input files compilation terminated. ./DirCompile.sh: line 1: e: command not found
gcc: fatal error: no input files compilation terminated. ./DirCompile.sh: line 1: e: command not found
gcc: fatal error: no input files compilation terminated. ./DirCompile.sh: line 1: e: command not found
gcc: fatal error: no input files compilation terminated.
תודה רבה
_____________________________________
Ramboli
נערך לאחרונה ע"י ramboli בתאריך 25-06-2016 בשעה 10:02.
|