![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
how to get rid of ==>
ok the assignment question:
That English paper you were writing on the works of Lewis Carroll is due in a few hours and you have forgeotten the name of the text file in which you has written a number of quotations to use in your paper. Luckily, you know that the file is somewhere in your ~/UnixCourse directory or in some subdirectory directly or indeirently within it. You also know that the file name ended in '.txt'. You are pretty sure that you could recognize the file from just the first line. You seem to recall having heard that there is a Unix command head that will print the first few lines of any file and suspect that, with the proper parameters, it could be used to print just the first line. (Hint - part of your task in this question is to show that you can use the built-in Unix help facilities.) find command problems redirectionAsst But you really don't want to type that command out for every file or even every directory. What command would you give to produce a listing of the names of all the text files in ~/UnixCourse or its subdirectories (possibly nested several layers deep) followed immediately by the first line of text within that file? E.g., to produce a listing looking like this: /home/yourname/UnixCourse/foo.txt When in the course of human development /home/yourname/UnixCourse/Quotations/bar.txt Curiouser and curiouser! finding a file and the first line of the text Note that the output format must look like the example above. (That's not unreasonable, as one of the things you should have learned from this lesson is that the output of one command is often fed into later commands, which must be able to read it.) In particular, solutions that add extreneous characters around the file name (e.g., << or ==>) are not correct. I was able to come up with : Code:
find /home/yournameUnixCourse/ -name "*.txt" -exec head -n1 -v {} \;
How do i get rid of the ==> ? or is there another command that might work? Last edited by Yogesh Sawant; 04-20-2009 at 04:49 AM.. Reason: added code tags |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|