Unix find and head command help

 
Thread Tools Search this Thread
Homework and Emergencies Homework & Coursework Questions Unix find and head command help
# 8  
Old 04-22-2012
I'm using putty in wndows 7
Code:
find ~/UnixCourse -type f -name "*.txt" -print

shows me all the text files and when i add
Code:
-exec head -n1 {} \;

it shows the first line underneath. however, when i try it within the hw assignment on the same program i get this:
Code:
find 'head' terminated by signal 13
head: error reading '../fileAsst/TweedleDee/hatters.txt': is a directory

and it says that for every text file within UnixCourse and all its sub directories. I can't understand why i get a different output.

Last edited by methyl; 04-22-2012 at 07:15 PM.. Reason: please use code tags
# 9  
Old 04-22-2012
Quote:
Originally Posted by partieboi37
I'm using putty in wndows 7
You're mistaking the TV for the channel, PUTTY is not UNIX, PUTTY is just a terminal emulator used to talk to other systems.

If you don't know what your system is, you should find out because it's important. uname -a
# 10  
Old 04-22-2012
ok my bad.
linux atria 2.6.38-8-server #42-Ubuntu SMP Mon Apr 11 03:49:04 UTC 2011 x86_64 x86_64 x86_64 GNU/Linux

Last edited by methyl; 04-22-2012 at 07:16 PM.. Reason: please use code tags
# 11  
Old 04-22-2012
when i try it within the hw assignment
Please post the script you ran which produced the error messages.


Ps. Does my script in post #3 run on your system and produce the desired result?
(It will tell us a lot about your local system).
# 12  
Old 04-22-2012
the first code you posted didn't work, but your second i just added
Code:
-exec -head -n1 {} \;

and it worked. they way we're supposed to do the assignment is we have two sessions of putty up on the same server. on one it has a question that we have to provide code to answer. on the other, we try out code to answer the question. so the script is
Code:
find ~/UnixCourse -type f -name "*.txt" -print -exec -head -n1 {} \;

when i execute it, it gives me (or at least i think it gives me) the desired output, but when i execute in the assignment in the same program it gives me the error message.
Moderator's Comments:
Mod Comment Link: How to use [code] tags

Last edited by Scrutinizer; 04-23-2012 at 06:34 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Head command queries

we have a file as below AREA,COUNTRY,RANK A,MX,1 A,MX,2 A,MX,5 A,MX,8 A,IN,7 A,IN,5 A,IN,21 B,CN,6 B,CN,2 B,CN,8 B,CN,0 we need the TOP 2 RANK records for the combination of Area, Country as below. i know head -2, which gives top 2 records from file but not sure it lists based on... (7 Replies)
Discussion started by: JSKOBS
7 Replies

2. Homework & Coursework Questions

UNIX head command not working?

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: Write a script that allows the user to print the first n lines or the last n lines of every file in the... (18 Replies)
Discussion started by: lukefrost96
18 Replies

3. HP-UX

How to find the head cleaning history on HP HP MSL4048 1 LT0-4 Ultrium 1840?

Please guide me how to get the head cleaning history on HP HP MSL4048 1 LT0-4 Ultrium 1840. (0 Replies)
Discussion started by: marunmeera
0 Replies

4. Shell Programming and Scripting

Diff/head - not sure if this is the right command to use

Hi, I need some advise on whether there is a better way of doing what I am currently planning to do. Perhaps I should be using arrays instead of re-directing output to files? I need to use a tool/program named ADRCI provided by Oracle to remove trace files that it generates. Honestly it is... (1 Reply)
Discussion started by: newbie_01
1 Replies

5. UNIX for Dummies Questions & Answers

find and head -1

i have lots of files in /law/prod and /law/dev, such as AP20PD, AP20WS, AP20.scr, AP20.rpt if i am in /law DIR find . -name AP20PD, found in /law/prod and /law/dev i want to head -1 AP20PD from both location and >> /tmp/test.log can i use find and head in one line ? ----------... (1 Reply)
Discussion started by: tjmannonline
1 Replies

6. Shell Programming and Scripting

head command with more than one file

Hi, I have the following problem. I have files with one column of data (let's say file1.dat, file2.dat...file6.dat), and I would like to record the first value of the column of each file into another file (let's name it fileall.dat), which would have the the six values, one in each column. I use to... (4 Replies)
Discussion started by: josegr
4 Replies

7. UNIX for Dummies Questions & Answers

alternative for head command

Hi friends,I am new to unix and this is really a dummy question.but please help me out. How to simulate head command without using head command??? also tail command too,also more command. it is given as a homework to do....please tell me how to do (2 Replies)
Discussion started by: nikhilneela
2 Replies

8. Shell Programming and Scripting

Little bit weired : Find files in UNIX w/o using find or where command

Yes , I have to find a file in unix without using any find or where commands.Any pointers for the same would be very helpful as i am beginner in shell scritping and need a solution for the same. Thanks in advance. Regards Jatin Jain (10 Replies)
Discussion started by: jatin.jain
10 Replies

9. Shell Programming and Scripting

head command

Hi All, How can the head command be used to extract only a particular line. By default head -n filename displays the first n lines. I want only the nth line. I couldn't get it from forum search. Thanks, Sumesh (6 Replies)
Discussion started by: sumesh.abraham
6 Replies
Login or Register to Ask a Question