LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-01-2011, 04:16 PM   #1
bobocheez
LQ Newbie
 
Registered: Apr 2011
Posts: 2

Rep: Reputation: 0
find and extract data


Hi,
I want get the information from a directory full of files.

What I have so far is this:
Code:
find <path> -exec head {} \; | tail -2
My question is, how do I get that certain section from each file, since tail will only affect the last file. I've tried piping head and tail to sh but that's not available due to permissions.
 
Old 04-01-2011, 04:25 PM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
Hi, welcome to LQ!

Can you please be more specific about the desired result? What
you're doing is outputting the head of each file (or directory,
whatever that may give you), and looking at the last two lines
of the combined output.



Cheers,
Tink
 
1 members found this post helpful.
Old 04-01-2011, 04:25 PM   #3
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978
Code:
find <path> -exec bash -c "head {} | tail -2" \;
 
2 members found this post helpful.
Old 04-01-2011, 05:04 PM   #4
bobocheez
LQ Newbie
 
Registered: Apr 2011
Posts: 2

Original Poster
Rep: Reputation: 0
That's what I was looking for. Thanks colucix.

Tinkster, I wanted to find each file in a directory, and get lines 9 and 10 from each file
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
website data extract Galib Programming 2 12-18-2010 04:55 AM
Extract Data between XML tags aharrison Linux - Newbie 13 11-17-2010 07:28 PM
Extract Data using CURL ludo33 Programming 4 11-29-2009 02:17 AM
extract data from link jindalarpan Linux - Software 5 09-21-2009 08:50 PM
Extract data ust Linux - General 1 10-23-2003 05:45 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:44 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration