Lost file


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Lost file
# 1  
Old 02-26-2009
Lost file

I have another problem. I have a text file in which I had written a number of quotations to use in my paper. Luckily, I know that the file is somewhere in my ~/UnixCourse directory or in some subdirectory directly or indeirently within it. I also know that the file name ended in '.txt'. I know i can recognize the file from just the first line.
I 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. But I really don't want to type that command out for every file or even every directory. What command would I need 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.txtWhen in the course of human development/home/yourname/UnixCourse/Quotations/bar.txtCuriouser and curiouser!I know I need to use a find command to walk through the subdirectoriesPlease help! Thanks in advance!!!
# 2  
Old 02-26-2009
By lost you mean - I cannot find it - or it doesn't exist?

If 'I cannot find it' try:
Code:
find /directory/path/to/search -user myusername -name '*.txt' |
while read filename
do
      echo "$filename"
      head -2 $filename
done

If it doesn't exist we cannot help.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Solaris

Lost /etc/passwd file

Hello, I'm trying to recover my /etc/passwd file, but I can't make it work. Im doing the following: 1. Booting from cd-rom: 2. Mounting hard disk drive 3. Copying my passwd and shadow files to /a/etc/ 4. Unmounting Hard disk: 5. Rebooting 6. Stopping my OS from booting ( by pressing... (11 Replies)
Discussion started by: alvaradogunner
11 Replies

2. Shell Programming and Scripting

Finding my lost file by searching for words in it

Got a question for you guys...I am searching through a public directory (that has tons of files) trying to find a file that I was working on a longggggg time ago. I can't remember what it is called, but I do remember the content. It should contains words like this: Joe Pulvo botnet zeus... (5 Replies)
Discussion started by: statichazard
5 Replies

3. Solaris

Lost /var/sadm/install/contents file and /var/sadm/pkg

Hello, I recently found that my /var/sadm/install/contents, ~/admin/default, /var/spool/patch and /var/spool/pkg files were empty. This broke the pkginfo, pkgchk and other package related tools. The pkgmap no longer points to where the applications have been installed. I have replaced the... (0 Replies)
Discussion started by: ronin42
0 Replies

4. UNIX for Dummies Questions & Answers

Lost my Way

I want to execute my own utilities from my bin folder without having to specify paths at run time - i.e. just enter name on command line - to do this my search path needs to be set up at login time - when I do this the path is not getting set right apparently(?) - PATH echos OK but the search... (0 Replies)
Discussion started by: robert stansel
0 Replies

5. UNIX for Dummies Questions & Answers

I am so lost...

I have been using linux now for about 6 months. I like it although it was quite a learning process. Pretty simple for the most part. Here is my prob... The first time I installed linux on my computer it went in just fine, no problems. It did eventually crash though and I had to re-install it.... (2 Replies)
Discussion started by: Treb
2 Replies

6. Solaris

Lost space on file system

Hi everybody, I got a problem on my SUN server in Solaris 9. I'll try to explain, if somebody could help me. I have mounted some volumes in RAID 0+1, that is stripped slices and then mirror. To be clear the result of metastat d80 is as follow : d80: Mirror Submirror 0: d81 State:... (2 Replies)
Discussion started by: aribault
2 Replies

7. Filesystems, Disks and Memory

Lost Data Lost Admin

First time so excuse my ignorance please. I may not be accurately describing the issue. I have inherited a small lab mostly SUN V120s. We lost power and are trying to recover. Nope no backups... The primary issue I have is 1 box is an Oracle Server. It has 2 36Gb harddrives. I am able to... (3 Replies)
Discussion started by: murphsr
3 Replies

8. UNIX for Dummies Questions & Answers

So lost

I have been reading up on starting a website, but i am still lost. I am in much need of assistance. Kind of a step by step because i still don't know where to start. please help. thank you (1 Reply)
Discussion started by: sweetie020602
1 Replies
Login or Register to Ask a Question