4. Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course):
York University, Toronto, Canada, Bil , cse 203 1
Last edited by Scott; 11-26-2012 at 04:54 PM..
Reason: Post restored; Thread Closed.
A single fi is enough to close the if elif. For testing if file can be compiled, it is clearly mentioned in assignment to use cc compiler without options. Use regex to test for integers:-
1. When you say "compare files", what exactly you want to do?
2. To check if a C program can compile or not, pass the C file to the C-compiler' for e.g., cc test.c and check the exit status echo $?. Anything other than 0 would mean compilation was not a success.
compare files:
I mean I'm given the path to a directory. How do I go into the directory, and how can I tell it's a .in file and find a corresponding .out file?
I meant to write:
Can I still use this?
I don't know how to get the C program from the second argument path...
I'm not sure if this is the correct way.
So, I figured out:
I think this means it finds all the .in files in the path of argument 1.
Good research skills! Many people here are not at all able to independently come up with an at least valid try.
Alas, this line might even work, so when i tell you that there are a few problems with it - please believe me! I'll try to explain:
first problem: proper quoting
This will work as long as "$1" contains only "normal" paths, like "/some/dir". It will fail, though, when the path contains a space, because a space character is also used by the shell to delimit arguments. Consider the following two lines:
the first command gets 3 arguments, "arg1", "arg2" and "arg3". The second command only gets two: "arg1" and "arg2 arg3". The double quote in this case tells the shell to treat the blank like a normal character. Because it won't hurt script programmers routinely protect their variables:
next problem: where do you want to search?
"find" is a command which searches recursively. That is, it finds files not only in the directory it starts in, but in every subdirectory there might be too. Do you want that? Or do you want to only search in the directory you named? Depending on your answer you may have to either modify "find" (read the man page about the "-prune"-option) to only search this directory and not its subdirectories or use "ls" instead of find.
last problem: subshell invocation
it is possible to invoke a series of commands and fill their output to a variable. Historically this has been done with backticks, like you did. Still, backticks have some severe limitations and are deprecated. Instead there is the "$(...)". Alas, there are still a lot of examples on the net with backticks. Believe me, they are all flawed in this regard. Backticks do not offer a single advantage over the modern subshell invocation but a lot of disadavantages: cannot be nested, cannot be quoted, just to name two. Therefore:
Hi everyone, first time visitor to these forums here.
Keeping a long story short I've been attempting to learn how to code in bash. I have VERY little previous experience with coding languages besides simply copying and pasting batch scripts for Windows. So, with that in mind I've followed a... (4 Replies)
Hi,
can someone explain how this aliases work:
alias m 'if ( \!:$ =~ *gz) set status = 1 && most \!:$ || gzcat \!:1 | most '
I mean, I know what it does, but I don't know how
- what is \!:$ and \!:1
- how do it used the && and ||
- what it does with status variable?
thanks (3 Replies)
So guys basically I was really sick and couldn't attend the labs and lectures and I went to my lecture hoping he would say ok I will help you from the start but he just said google it. So If it's possible to make the assignment and explain more in detail why is that would be really helpfull.
I can... (1 Reply)
Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!
1. The problem statement, all variables and given/known data:
"Create a shell script that changes the selected word to another word in all files from selected archive. The... (1 Reply)
Hello,
I'm new to Sheel script and I need your help for a script I need to develop (for me).
Indead, I have a software which log all entry from internet and save it in text file.
But, the log is practically unreadable because every 256 characters jump to a new line (even if the message is... (5 Replies)
I have been following a tutorial on bash which has proven to be very helpful. However, i am stuck with a command not found issue when asking for a y/n response from the user. Below is the part of code I believe is giving me grief... I have been trying to work through this for 3 hours now.... Please... (5 Replies)
. ./testFile.sh
url=http://ichart.finance.yahoo.com/table.csv?s= suf=&d=5&e=9&f=2009&g=d&a=1&b=4&c=1999&ignore=.csv
wget $url$s1$suf;
sleep 10;
cat header.txt > $s1.txt;
chmod 777 $s1.txt;
sed '1d' table.csv?s\=$s1 >> $s1.txt;
rm -Rf table*
Very new at shell scripting as you can see... (3 Replies)
I have a folder with lots of file. e.g. a.txt, b.txt, c.txt.... I want to put these files from the source directory and place them in a destination directory in a specific order, such as /destination/a/a.txt, /destination/b/b.txt, /destination/c/c.txt, ......
Please help. Thx :confused: (3 Replies)
Dear All,
I'm trying to write a shell script that continously checks a certain folder. When a file is placed in the directory securely copies the file to another server.
I've got the secure copying working, but I don't know how to contiously check a directory for a new file and then use that... (3 Replies)