Sponsored Content
Top Forums Shell Programming and Scripting Read n lines from a text files getting n from within the text file Post 302853341 by malandisa on Friday 13th of September 2013 05:42:20 PM
Old 09-13-2013
Thank you again everyone especially Don for your assistance. This has worked perfectly, and finally here is my script that plots the data the way I want

Code:
#! /bin/bash
# 
# read each block and output to a file
awk '
$1 == ">" {
        if(f) close(f)
        f="file" ++n".txt"
        next
}
{       print > f
}' UNZA2250.txt
# count the # of block to plot
nx=`awk '{c+=gsub(s,s)}END{print c}' s='>' UNZA2250.txt`
echo $nx
# --------------------------------------
gnuplot << EOF
# set size 1.7,1.3
set terminal postscript eps enhanced color "Helvetica" 30
set output "fig.eps"
set ylabel "TEC"
set xlabel "hour"
set xrange [0:24]
set yrange [0:120]
set nokey

filename(n) = sprintf("file%d.txt", n)
plot for [i=1:$nx] filename(i) using 1:4 with lines
EOF
# view the output image
gv fig.eps &
# 
# remove the text files used for ploting
rm file*.txt

The data file is attached, the output figure is what I am looking for.

If there is a better and/or easier way to achieve this, I would love to learn. Especially if there can be a way to use the awk within gnuplot without having to output the data to the files as I have done here.

Thank you again
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

read list of filenames from text file and remove these files in multiple directories

I have a large list of filenames from an Excel sheet, which I then translate into a simple text file. I'd like to use this list, which contains various file extensions , to archive these files and then remove them recursively through multiple directories and subdirectories. So far, it looks like... (5 Replies)
Discussion started by: fxvisions
5 Replies

2. Shell Programming and Scripting

Read any lines of text from file

Witam wszystkich , Jest to moj pierwszy post i już prośba ale gdybym potrafił zaradzić problemowi to nie zawracałbym nikomu głowy . mianowicie : Mam jakis 'plik' w ktorym są osadzone pojedyncze i zmienne słowa po jednym w lini czyli : test1 tekttw resst .... itd. Moje... (6 Replies)
Discussion started by: versace
6 Replies

3. Shell Programming and Scripting

Shell script to read lines in a text file and filter user data

hi all, I have this file with some user data. example: $cat myfile.txt FName|LName|Gender|Company|Branch|Bday|Salary|Age aaaa|bbbb|male|cccc|dddd|19900814|15000|20| eeee|asdg|male|gggg|ksgu|19911216||| aara|bdbm|male|kkkk|acke|19931018||23| asad|kfjg|male|kkkc|gkgg|19921213|14000|24|... (4 Replies)
Discussion started by: srimal
4 Replies

4. Shell Programming and Scripting

[bash help]Adding multiple lines of text into a specific spot into a text file

I am attempting to insert multiple lines of text into a specific place in a text file based on the lines above or below it. For example, Here is a portion of a zone file. IN NS ns1.domain.tld. IN NS ns2.domain.tld. IN ... (2 Replies)
Discussion started by: cdn_humbucker
2 Replies

5. UNIX for Dummies Questions & Answers

Extracting lines from a text file based on another text file with line numbers

Hi, I am trying to extract lines from a text file given a text file containing line numbers to be extracted from the first file. How do I go about doing this? Thanks! (1 Reply)
Discussion started by: evelibertine
1 Replies

6. Shell Programming and Scripting

Read text between two lines containing a string

Hi, I have text file like the following: Start a b 121 c d End Start a 31 e f End Start p o i k (5 Replies)
Discussion started by: ysrini
5 Replies

7. Shell Programming and Scripting

Comparing 2 text files & downloading a file if the last lines are different

Hello I'm having a little difficulty in writing a shell script for a few simple tasks. First I have two files "file1.txt" and "file2.txt" and I want to read and compare the last line of each file. The files look like this. File1.txt File2.txt After comparing the two lines I would... (2 Replies)
Discussion started by: RustikGaming
2 Replies

8. Shell Programming and Scripting

Extracting lines from text files in folder based on the numbers in another file

Hello, I have a file ff.txt that looks as follows *ABNA.txt 356 24 36 112 *AC24.txt 457 458 321 2 ABNA.txt and AC24.txt are the files in the folder named foo1. Based on the numbers in the ff.txt file, I want to extract the lines from the corresponding files in the foo1 folder and... (2 Replies)
Discussion started by: mohamad
2 Replies

9. Shell Programming and Scripting

Read text between regexps and write into files based on a field in the text

Hi, I have a huge file that has data something like shown below: huge_file.txt start regexp Name=Name1 Title=Analyst Address=Address1 Department=Finance end regexp some text some text start regexp Name=Name2 Title=Controller Address=Address2 Department=Finance end regexp (7 Replies)
Discussion started by: r3d3
7 Replies

10. Shell Programming and Scripting

Match text to lines in a file, iterate backwards until text or text substring matches, print to file

hi all, trying this using shell/bash with sed/awk/grep I have two files, one containing one column, the other containing multiple columns (comma delimited). file1.txt abc12345 def12345 ghi54321 ... file2.txt abc1,text1,texta abc,text2,textb def123,text3,textc gh,text4,textd... (6 Replies)
Discussion started by: shogun1970
6 Replies
APSFILTER-BUG(1)					    BSD General Commands Manual 					  APSFILTER-BUG(1)

NAME
apsfilter-bug -- create a half-automatic bug report for apsfilter SYNOPSIS
apsfilter-bug OPTIONS
none DESCRIPTION
With the apsfilter-bug script you can automatically create a bug report for apsfilter(1). A template report file is created which you can edit with your favourite editor ( emacs(1) by default, or whatever is entered in the environment variable EDITOR ). You will see a couple of lines starting with '#'; these lines will be removed before the report is sent. So if you want to use the '#' char- acter at the beginning of a line, just indent it with a space. A very important piece of the bug report is the debugging log created by aps2file(1), probably with a command like aps2file -D -o /dev/null [-P...] [-Z...] [input] 2> log.txt Unless you don't even have a chance to create a debugging log, it is crucial for serious bug hunting. After you have filled in as much (useful) information as possible, you must save the file under its original name, then exit your editor. If you invoked apsfilter-bug by accident, or if you need some additional system information to include into the bug report, just exit your editor without saving the file. NOTES
In addition to the stuff you've edited, some more information is appended to the bug report automatically: apsfilter version 7.2.6-stable ghostscript version (from 'gs --version') system id (from 'uname -a') configure options --prefix=/usr --sysconfdir=/etc --mandir=/usr/share/man --with-awk=/usr/bin/awk --with-sendmail=/usr/sbin/sendmail shell executable /bin/bash awk executable /usr/bin/awk sendmail executable /usr/sbin/sendmail FILES
/usr/bin/aps2file script to create debugging output SEE ALSO
apsfilter(1), aps2file(1) BUGS
See apsfilter software center - http://www.apsfilter.org/ - for new versions, bugfixes and known bugs. Please use the new tool apsfilter-bug(1) to release bug- or problem reports. It automatically presents you a form in an editor window which asks you some standard questions. If you save and quit the editor session, then this report is sent automatically via e-mail to the proper apsfilter mailinglist. If apsfilter fails to print something or prints it in a way you wouldn't expect and you want to report an apsfilter error then please save the debugging output of one print session using the new aps2file(1) utility by typing aps2file -D -Z options file > /dev/null 2> file.debug and including the debugging output in the file file.debug into the edit session of the apsfilter-bug utility, so that it is included into the mail to the apsfilter mailinglist. Please note that you need to run /bin/sh (Bourne Shell), bash or a compatible shell, so that the above mentioned output redirection works. Under C-shell (/bin/csh) or tcsh it would't work. If you don't know, then simply make sure you use the Bournce shell by typing /bin/sh or bash, then you should have no problems with redirection of stdout and stderr (> /dev/null 2> file.debug). DOCUMENTATION
See official apsfilter homepage http://www.apsfilter.org/handbook.html Apsfilter Handbook including the Frequently Asked Questions (FAQ) USER FORUM
Please send questions to the official apsfilter help channel apsfilter-help@apsfilter.org. The above section BUGS and the file HOWTO-BUGREPORTS tells you how to report bugs. If you want to know how to troubleshoot your apsfilter installation, please read the manpage aps2file(1) and apsfilter-bug(1) as well as the Apsfilter Handbook carefully. HISTORY
The apsfilter-bug manpage has been written by Michael LoBin <phallobst@web.de> and first appeared in apsfilter V 7.1.0. BSD
Dec 26, 2001 BSD
All times are GMT -4. The time now is 09:35 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy