Sponsored Content
Top Forums Shell Programming and Scripting Read n lines from a text files getting n from within the text file Post 302853275 by Don Cragun on Friday 13th of September 2013 02:50:46 PM
Old 09-13-2013
I repeat: "Note that there are only 14 lines following the 1st line, but the 1st line contains #data: 15 ;". The script you're using assumes that the 15 in the 1st line of your input file is correct and your output is wrong because that 15 should be 14 for the data in your input file.

If your input data is invalid, you will not get valid output. Or more commonly: GIGO (Garbage in; garbage out).

You can get the output you said want from that input with the following awk script (although I STRONGLY suggest that you not put a space in your filenames):
Code:
awk '
$1 == ">" {
        if(f) close(f)
        f="file " ++n
        next
}
{       print > f
}' UNZA2250.txt

This User Gave Thanks to Don Cragun For This Post:
 

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
trbdf(1)							   User Manuals 							  trbdf(1)

NAME
trbdf - convert BDF-font from one encoding to other SYNOPSIS
trbdf -C | -l | -h trbdf [-s] [-f input-codeset ] [-t output-codeset ] [--foundry[=] new-foundry ] BDF-font DESCRIPTION
trbdf is a program for translation of BDF fonts from one encoding to other. One exciting feature of trbdf is that it tries to approximate the symbols that miss from the font or from the encoding of the font with existing symbols when possible. If the option -s or --gen-script is given trbdf will generate an awk(1) script for translation of BDF-fonts for fixed combination of input- codeset and output-codeset This is useful for faster convertion of many files. This script is used as filter. If none of -C, -s, -l, -h and their equivalents is given the BDF-font will be read assuming it is coded with codeset input-codeset On stan- dard output it will be recoded so to use codeset output-codeset Both input-codeset and output-codeset are case insensitive and default to `cp1251'. OPTIONS
-C, --copyright Display copying conditions and warranty information. -s, --gen-script Generates conversion script for given input and output encodings instead to convert BDF-font. This option is usefull if you have to convert many fonts. The generated script expects the input font from its standard input and outputs the converted font. -l, --list List all known codesets. -h, --help Display this help and exit. -f input-codeset, --from[=]input-codeset Codeset of the source font. -f output-codeset, --to[=]output-codeset Codeset of the generated font. --foundry[=]new-foundry Use this option if you want to change the foundry of the generated fonts. AUTHOR
Anton Zinoviev <anton@lml.bas.bg>, <zinoviev@fmi.uni-sofia.bg> SEE ALSO
bdftopcf(1x) trscripts NOV 2002 trbdf(1)
All times are GMT -4. The time now is 02:59 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy