extracting information

extracting information

Post by Lars Rolan » Sat, 28 Feb 2004 19:36:14



I have a large collection of files where most of the information's are useless,
what i want is to extract the information i need out of them and
delete the rest.

Eg.  the files contain a line starting with:

Information:

What i want to do is to delete the rest of the file except the line
starting with Information: - can this be done ???

 
 
 

extracting information

Post by Stefan Lagotzk » Sat, 28 Feb 2004 20:34:31


Hi Lars,

grep '^Information:' in.txt > out.txt
awk '/^Information:/ {print $0}' in.txt > out.txt

   Lars Roland:

Quote:> What i want to do is to delete the rest of the file except the line
> starting with Information: - can this be done ???

mv out.txt in.txt

Stefan

.

 
 
 

extracting information

Post by John W. Krah » Sun, 29 Feb 2004 09:54:23



> I have a large collection of files where most of the information's are useless,
> what i want is to extract the information i need out of them and
> delete the rest.

> Eg.  the files contain a line starting with:

> Information:

> What i want to do is to delete the rest of the file except the line
> starting with Information: - can this be done ???

perl -i -ne'print if /^Information:/' *

John
--
use Perl;
program
fulfillment

 
 
 

extracting information

Post by rakesh shar » Sun, 29 Feb 2004 14:27:53



> I have a large collection of files where most of the information's are useless,
> what i want is to extract the information i need out of them and
> delete the rest.

> Eg.  the files contain a line starting with:

> Information:

> What i want to do is to delete the rest of the file except the line
> starting with Information: - can this be done ???

If there are not too many files in your current directory, then this will do:

for fname in ./* ./.*;do
   [ -f /tmp/LOGFILE ] && continue
   grep -l '^Information:' $fname > /dev/null && \
   sed -e '
      /^Information:/q;d
   ' $fname >> /tmp/LOGFILE
done

 
 
 

1. Extract information between tags.

Found a solution but it must be a better solution :)

INFO=$(awk '/<START>/,/<STOP>/' $FILE)
INFO=${INFO#*'<START>'}   # Or INFO##*..
INFO=${INFO%'<STOP>'*}    # Or INFO%%..

* Sent from RemarQ http://www.remarq.com The Internet's Discussion Network *
The fastest and easiest way to search and participate in Usenet - Free!

2. uuchk/uucico dies

3. What's the most unique method to extract information?

4. Partition

5. Extracting Information from binaries

6. solaris 26 ntp vs public xntp

7. extracting information from dhcpcd to use statically

8. WinBond W89c940F = unknown pci-device :-(

9. How Could I extract this information ?

10. need to extract two bits of information from a file

11. tar 1.12 *always* extracts ownership information?

12. Extracting exported symbol information from shared object files

13. Extract system information under HP-UX