Sponsored Content
Top Forums Shell Programming and Scripting Read n lines from a text files getting n from within the text file Post 302852953 by malandisa on Thursday 12th of September 2013 08:16:37 PM
Old 09-12-2013
Read n lines from a text files getting n from within the text file

I dont even have a sample script cause I dont know where to start from. My data lookes like this
Code:
> sat#16 #data: 15 site:UNZA baseline:  205.9151
  0.008   -165.2465     35.8109     40.6685     21.9148    121.1446     26.4629    -18.4976     33.8722
  0.017   -165.2243     48.2201     40.6908     21.9058    120.8975     26.4179    -18.4794     33.8951
  0.025   -165.1857     41.5258     40.7293     21.9056    120.6503     26.3729    -18.4611     33.9179
  0.033   -165.1438     33.9471     40.7713     21.9072    120.4031     26.3278    -18.4427     33.9407
  0.042   -165.1106     40.8982     40.8045     21.9039    120.1559     26.2826    -18.4242     33.9635
  0.050   -165.0913     38.5970     40.8238     21.8932    119.9087     26.2375    -18.4056     33.9862
  0.058   -165.0968     43.7509     40.8183     21.8692    119.6616     26.1922    -18.3868     34.0089
  0.067   -165.0654     40.7461     40.8497     21.8649    119.4144     26.1470    -18.3680     34.0316
  0.075   -165.0817     46.2518     40.8334     21.8350    119.1672     26.1016    -18.3490     34.0542
  0.083   -165.0412     40.4513     40.8739     21.8355    118.9200     26.0563    -18.3299     34.0768
  0.092   -165.0533     44.7589     40.8617     21.8078    118.6728     26.0108    -18.3107     34.0994
  0.100   -165.0425     43.8650     40.8726     21.7924    118.4256     25.9653    -18.2913     34.1219
  0.108   -165.0378     39.0059     40.8773     21.7736    118.1784     25.9198    -18.2719     34.1444
  0.117   -165.0049     44.6828     40.9102     21.7699    117.9312     25.8741    -18.2523     34.1668
> sat#19 #data: 6 site:UNZA baseline:  235.0682
 17.900   -171.3423     62.8450     63.7259     26.5775    325.4868     15.0105     -7.3923     22.8404
 17.908   -171.5057     55.5991     63.5625     26.6247    325.4057     15.2054     -7.4669     22.8738
 17.917   -171.7347     53.3075     63.3335     26.6444    325.3236     15.4003     -7.5407     22.9067
 17.925   -172.0204     57.9098     63.0478     26.6402    325.2407     15.5952     -7.6138     22.9393
 17.933   -172.2141     50.7400     62.8541     26.6748    325.1568     15.7902     -7.6860     22.9714
 17.942   -172.4885     48.0680     62.5797     26.6751    325.0720     15.9851     -7.7575     23.0031
> sat# 1 #data: 8 site:UNZA baseline:  225.5519
  0.008   -148.7547     75.6631     76.7972     65.5288     89.3165     56.3463    -15.3538     30.6348
  0.017   -148.7668     73.5426     76.7851     65.5199     89.7731     56.3486    -15.3715     30.6350
  0.025   -148.7836     80.0087     76.7683     65.5057     90.2296     56.3488    -15.3892     30.6352
  0.033   -148.7821     76.5570     76.7698     65.5058     90.6859     56.3469    -15.4069     30.6354
  0.042   -148.7916     78.7440     76.7603     65.4952     91.1420     56.3430    -15.4246     30.6356
  0.050   -148.8006     74.6552     76.7513     65.4836     91.5978     56.3370    -15.4423     30.6359
  0.058   -148.8115     73.8469     76.7404     65.4692     92.0532     56.3289    -15.4600     30.6362
  0.067   -148.8211     75.2542     76.7308     65.4545     92.5083     56.3188    -15.4777     30.6365

and so on. I need the sript to read the first line with text and use the #data value to determine how many lines to read below this text line, then read those lines of data, then read the next line with text and use the #data value to count how namy lines to read below that and so on.

To be honext I have no idea where to start from. And honestly I am not completely new to shell scripting but this has challenged me to the core. This is not an assignment, its for my rresearch work am a seniour lecturer in the department of physics at the university of zambia in lusaka, zambia. I hope it is doable.

The read data can be directed to a gnuplot ot output to a file.

Thank you in advance
 

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
ASCII(7)						     Linux Programmer's Manual							  ASCII(7)

NAME
ascii - ASCII character set encoded in octal, decimal, and hexadecimal DESCRIPTION
ASCII is the American Standard Code for Information Interchange. It is a 7-bit code. Many 8-bit codes (such as ISO 8859-1, the Linux default character set) contain ASCII as their lower half. The international counterpart of ASCII is known as ISO 646. The following table contains the 128 ASCII characters. C program 'X' escapes are noted. Oct Dec Hex Char Oct Dec Hex Char ------------------------------------------------------------------------ 000 0 00 NUL '' 100 64 40 @ 001 1 01 SOH (start of heading) 101 65 41 A 002 2 02 STX (start of text) 102 66 42 B 003 3 03 ETX (end of text) 103 67 43 C 004 4 04 EOT (end of transmission) 104 68 44 D 005 5 05 ENQ (enquiry) 105 69 45 E 006 6 06 ACK (acknowledge) 106 70 46 F 007 7 07 BEL 'a' (bell) 107 71 47 G 010 8 08 BS '' (backspace) 110 72 48 H 011 9 09 HT ' ' (horizontal tab) 111 73 49 I 012 10 0A LF ' ' (new line) 112 74 4A J 013 11 0B VT 'v' (vertical tab) 113 75 4B K 014 12 0C FF 'f' (form feed) 114 76 4C L 015 13 0D CR ' ' (carriage ret) 115 77 4D M 016 14 0E SO (shift out) 116 78 4E N 017 15 0F SI (shift in) 117 79 4F O 020 16 10 DLE (data link escape) 120 80 50 P 021 17 11 DC1 (device control 1) 121 81 51 Q 022 18 12 DC2 (device control 2) 122 82 52 R 023 19 13 DC3 (device control 3) 123 83 53 S 024 20 14 DC4 (device control 4) 124 84 54 T 025 21 15 NAK (negative ack.) 125 85 55 U 026 22 16 SYN (synchronous idle) 126 86 56 V 027 23 17 ETB (end of trans. blk) 127 87 57 W 030 24 18 CAN (cancel) 130 88 58 X 031 25 19 EM (end of medium) 131 89 59 Y 032 26 1A SUB (substitute) 132 90 5A Z 033 27 1B ESC (escape) 133 91 5B [ 034 28 1C FS (file separator) 134 92 5C '\' 035 29 1D GS (group separator) 135 93 5D ] 036 30 1E RS (record separator) 136 94 5E ^ 037 31 1F US (unit separator) 137 95 5F _ 040 32 20 SPACE 140 96 60 ` 041 33 21 ! 141 97 61 a 042 34 22 " 142 98 62 b 043 35 23 # 143 99 63 c 044 36 24 $ 144 100 64 d 045 37 25 % 145 101 65 e 046 38 26 & 146 102 66 f 047 39 27 ' 147 103 67 g 050 40 28 ( 150 104 68 h 051 41 29 ) 151 105 69 i 052 42 2A * 152 106 6A j 053 43 2B + 153 107 6B k 054 44 2C , 154 108 6C l 055 45 2D - 155 109 6D m 056 46 2E . 156 110 6E n 057 47 2F / 157 111 6F o 060 48 30 0 160 112 70 p 061 49 31 1 161 113 71 q 062 50 32 2 162 114 72 r 063 51 33 3 163 115 73 s 064 52 34 4 164 116 74 t 065 53 35 5 165 117 75 u 066 54 36 6 166 118 76 v 067 55 37 7 167 119 77 w 070 56 38 8 170 120 78 x 071 57 39 9 171 121 79 y 072 58 3A : 172 122 7A z 073 59 3B ; 173 123 7B { 074 60 3C < 174 124 7C | 075 61 3D = 175 125 7D } 076 62 3E > 176 126 7E ~ 077 63 3F ? 177 127 7F DEL Tables For convenience, let us give more compact tables in hex and decimal. 2 3 4 5 6 7 30 40 50 60 70 80 90 100 110 120 ------------- --------------------------------- 0: 0 @ P ` p 0: ( 2 < F P Z d n x 1: ! 1 A Q a q 1: ) 3 = G Q [ e o y 2: " 2 B R b r 2: * 4 > H R f p z 3: # 3 C S c s 3: ! + 5 ? I S ] g q { 4: $ 4 D T d t 4: " , 6 @ J T ^ h r | 5: % 5 E U e u 5: # - 7 A K U _ i s } 6: & 6 F V f v 6: $ . 8 B L V ` j t ~ 7: ' 7 G W g w 7: % / 9 C M W a k u DEL 8: ( 8 H X h x 8: & 0 : D N X b l v 9: ) 9 I Y i y 9: ' 1 ; E O Y c m w A: * : J Z j z B: + ; K [ k { C: , < L l | D: - = M ] m } E: . > N ^ n ~ F: / ? O _ o DEL NOTES
History An ascii manual page appeared in Version 7 of AT&T UNIX. On older terminals, the underscore code is displayed as a left arrow, called backarrow, the caret is displayed as an up-arrow and the ver- tical bar has a hole in the middle. Uppercase and lowercase characters differ by just one bit and the ASCII character 2 differs from the double quote by just one bit, too. That made it much easier to encode characters mechanically or with a non-microcontroller-based electronic keyboard and that pairing was found on old teletypes. The ASCII standard was published by the United States of America Standards Institute (USASI) in 1968. SEE ALSO
iso_8859-1(7), iso_8859-10(7), iso_8859-13(7), iso_8859-14(7), iso_8859-15(7), iso_8859-16(7), iso_8859-2(7), iso_8859-3(7), iso_8859-4(7), iso_8859-5(7), iso_8859-6(7), iso_8859-7(7), iso_8859-8(7), iso_8859-9(7) COLOPHON
This page is part of release 3.44 of the Linux man-pages project. A description of the project, and information about reporting bugs, can be found at http://www.kernel.org/doc/man-pages/. Linux 2009-02-12 ASCII(7)
All times are GMT -4. The time now is 08:51 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy