File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Linux / UNIX and the fly likes done < $1? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » Linux / UNIX
Bookmark "done &lt; $1?" Watch "done &lt; $1?" New topic
Author

done &lt; $1?

Joe Allen
Ranch Hand

Joined: Nov 14, 2012
Posts: 93


I am confused with "done < $1". If taking away "< $1", would the code still work properly? Could anyone please explain this to me? Thanks.

"There are no dumb questions" quoted from HFSJ. "To err is human; to forgive is divine"
OCPJP 6, OCEJWCD 6
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30138
    
150

Joe,
In UNIX, the idiom to read a file is:

while read line; do
# code to do work
done < fileToRead

In your example, the code has abstracted "fileToRead" into a variable that is passed at the command line. That's what $1 is. The program won't work without < $1 because UNIX won't know what lines to read.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Joe Allen
Ranch Hand

Joined: Nov 14, 2012
Posts: 93
Hi Jeanne,

It is nice to see you are in this forum too. Thank you so much for the explanation.

Joe
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: done &lt; $1?
 
Similar Threads
How to read one file and replace contents in another file
Making multiple files from single file
Tomcat fails to restart with "Address already in use" exception
Execute String as a Unix Command
error starting up 2nd instance of tomcat