New to linux and needs help> Thanks
hi evry1.. today at campus we had tp just type in sum stuff in shell scripting. but i dont know what is happening. Sp could some1 please expalin each line of coding for me thanks.
the shell script is: for i in 1 2 3 do sort file${i} > newFile${i} if [ ! -e "file${i}" ] then echo "file${i} does not exist."; echo continue fi done for x in 1 2 3 do tail -1 newFile${x} >> out1 done sort -r out1 > assmnt rm newFile1 newFile2 newFile3 out1 |
First of all, please use decent thread titles that describe your question/problem. Saying that you need help is not useful. It's better to say what you need help with.
Secondly, please write out your words in full. Thirdly, when posting code here, put it between [code] tags to preserve indentation and aid readability. Surely if you're learning shell scripting in a class, they must give you some resources or something to read? Have you consulted that material? You might also want to look at this. For the commands used (e.g. sort and tail), look at their man pages to see what they do and how you can use them (e.g. "man sort"). |
No, I don't think we're interested in breaking it down line by line for you. You'll learn more by working it out yourself. :twocents:
But to give you a starting point, your script uses the following shell built-in features: variables for loops if statements [ tests echo continue > and >> file redirections And the following external commands: sort tail rm So once you know how each of these things works, you should be able to decode the script. I highly recommend reading through this guide. It covers all the basic concepts. http://mywiki.wooledge.org/BashGuide Then if there are any specific points that you still don't understand, we'll be happy to help you out with them. :study: |
Hi,
Welcome to LQ! Quote:
Code:
info here LQ Rules state; Quote:
FYI: Netiquette is a set of social conventions that facilitate interaction over networks, ranging from Usenet and mailing lists to blogs and forums. FYI: I suggest that you look at 'How to Ask Questions the Smart Way' so in the future your queries provide information that will aid us in diagnosis of the problem or query. Plus it is a very helpful reference to formalize your question and Subject title. Here at LQ we frown upon someone who cannot use full text and complete sentences. No SMS or tech speak! LQ is a world community so we can understand when someone has a problem forming good understandable communication when English is not the first language. If English is not your first language then I suggest that you learn to use a translator. BTW, LQ has a good spell checker. :) |
1. consult your class docs
2. ask your teacher 3. read http://rute.2038bug.com/index.html.gz http://tldp.org/LDP/Bash-Beginners-G...tml/index.html http://www.tldp.org/LDP/abs/html/ |
All times are GMT -5. The time now is 03:06 PM. |