Sponsored Content
Top Forums UNIX for Dummies Questions & Answers AWK, extract data from multiple files Post 302457973 by Liverpaul09 on Wednesday 29th of September 2010 08:25:30 AM
Old 09-29-2010
Quote:
Originally Posted by bartus11
Code:
awk 'FNR==1 && NR==1{printf FILENAME" "}FNR==1 && NR!=1{printf "\n"FILENAME" "}$1~"UWI" || $1~"LSR"{for (i=3;i<=NF;i++)printf $i" "}END{printf "\n"}' *.txt

It's going to take me a while to understand your code before I can fine tune it (I'm a beginner). It's close to being correct, but has a few problems.
- When the script finds the flag "UWI", it returns too much information (ie. Data1 + unecessary text). Note: The start and end points of the data I want to extract are fixed positions in each file.
- When the script finds the flag "LSR", it returns information to the right of what I want. The only difference between the UWI and LSR flags is that they are on different lines, the piece of text I want to extract from each line is positioned in the same place in each line.

Let me have a look at it today and I'll reply tomorrowSmilie.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

extract multiple cloumns from multiple files; skip rows and include filenames; awk

Hello, I am trying to write a bash shell script that does the following: 1.Finds all *.txt files within my directory of interest 2. reads each of the files (25 files) one by one (tab-delimited format and have the same data format) 3. skips the first 10 rows of the file 4. extracts and... (4 Replies)
Discussion started by: manishabh
4 Replies

2. UNIX for Dummies Questions & Answers

Using AWK: Extract data from multiple files and output to multiple new files

Hi, I'd like to process multiple files. For example: file1.txt file2.txt file3.txt Each file contains several lines of data. I want to extract a piece of data and output it to a new file. file1.txt ----> newfile1.txt file2.txt ----> newfile2.txt file3.txt ----> newfile3.txt Here is... (3 Replies)
Discussion started by: Liverpaul09
3 Replies

3. UNIX for Dummies Questions & Answers

awk, extract last line of multiple files

Hi, I have a directory full of *.txt files. I would like to print the last line of every file to screen. I know you can use FNR for printing the first line of each file, but how do I access the last line of each file? This code doesn't work, it only prints the last line of the last file:BEGIN... (5 Replies)
Discussion started by: Liverpaul09
5 Replies

4. Shell Programming and Scripting

extract data with awk from html files

Hello everyone, I'm new to this forum and i am new as a shell scripter. my problem is to have html files in a directory and I would like to extract from these some data that lies between two different lines Here's my situation <td align="default"> oxidizability (mg / l): data_to_extract... (6 Replies)
Discussion started by: sbobotex
6 Replies

5. Shell Programming and Scripting

Extract data with awk and write to several files

Hi! I have one file with data that looks like this: 1 data data data data 2 data data data data 3 data data data data . . . 1 data data data data 2 data data data data 3 data data data data . . . I would like to have awk to write each block to a separate file, like this: 1... (3 Replies)
Discussion started by: LinWin
3 Replies

6. UNIX for Dummies Questions & Answers

Extract common data out of multiple files

I am trying to extract common list of Organisms from different files For example I took 3 files and showed expected result. In real I have more than 1000 files. I am aware about the useful use of awk and grep but unaware in depth so need guidance regarding it. I want to use awk/ grep/ cut/... (7 Replies)
Discussion started by: macmath
7 Replies

7. Shell Programming and Scripting

awk -- Extract data from html within multiple tags as reference

Hi, I'm trying to get some data from an html file, but the problem is before it can extract the information I have multiple patterns that need to be passed through. https://www.unix.com/shell-programming-scripting/150711-extract-data-awk-html-files.html Is a similar problem. The only... (5 Replies)
Discussion started by: counfhou
5 Replies

8. Shell Programming and Scripting

Extract data in tabular format from multiple files

Hi, I have directory with multiple files from which i need to extract portion of specif lines and insert it in a new file, the new file will contain a separate columns for each file data. Example: I need to extract Value_1 & Value_3 from all files and insert in output file as below: ... (2 Replies)
Discussion started by: belalr
2 Replies

9. Shell Programming and Scripting

awk - Multiple files - 1 file with multi-line data

Greetings experts, Have 2 input files, of which 1 file has 1 record per line; in 2nd file, multiple lines constitute 1 record; Hence declared the RS=";" Now in the first file which ends with ";" at each line of the line; But \nis also being considered as part of the data due to which I am... (1 Reply)
Discussion started by: chill3chee
1 Replies

10. Shell Programming and Scripting

Compare 2 files and extract the data which is present in other file - awk is not working

file2 content f1file2 content f1,1,2,3,4,5 f1,2,4,6,8,10 f10,1,2,3,4,5 f10,2,4,6,8,10 f5,1,2,3,4,5 f5,2,4,6,8,10awk 'FNR==NR{a;next}; !($1 in a)' file2 file1output f10,1,2,3,4,5 f10,2,4,6,8,10 f5,1,2,3,4,5 f5,2,4,6,8,10awk 'FNR==NR{a;next}; ($1 in a)' file2 file1output nothing... (4 Replies)
Discussion started by: gksenthilkumar
4 Replies
GNUNET-UNINDEX(1)					      General Commands Manual						 GNUNET-UNINDEX(1)

NAME
gnunet-unindex - a command line interface for deleting indexed files from GNUnet SYNOPSIS
gnunet-unindex [OPTIONS] FILENAME DESCRIPTION
gnunet-unindex is used for deleting indexed files from GNUnet. -c FILENAME, --config=FILENAME use config file (defaults: ~/.gnunet/gnunet.conf) -h, --help print help page -L LOGLEVEL, --loglevel=LOGLEVEL Change the loglevel. Possible values for LOGLEVEL are NOTHING, ERROR, WARNING, INFO and DEBUG. -v, --version print the version number -V, --verbose be verbose NOTES
You can only unindex files that you indexed and that you still have available locally in full. You should use gnunet-unindex on files that you indexed (not inserted) and that you are going to delete or move locally. FILES ~/.gnunet/gnunet.conf GNUnet configuration file REPORTING BUGS
Report bugs to <https://gnunet.org/bugs/> or by sending electronic mail to <gnunet-developers@gnu.org> SEE ALSO
gnunet-fs-gtk(1), gnunet-publish(1), gnunet-search(1), gnunet-download(1), gnunet.conf(5) GNUnet 6 Sep 2009 GNUNET-UNINDEX(1)
All times are GMT -4. The time now is 11:06 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy