Sponsored Content
Top Forums Shell Programming and Scripting awk/sed script to print each line to a separate named file Post 302541619 by kalelovil on Monday 25th of July 2011 07:51:26 AM
Old 07-25-2011
awk/sed script to print each line to a separate named file

I have a large 3479 line .csv file, the content of which looks likes this:

Code:
1;0;177;170;Guadeloupe;x
2;127;171;179;Antigua and Barbuda;x
3;170;144;2;Umpqua;x
4;170;126;162;Coos Bay;x
...
1205;46;2;244;Unmak Island;x
1206;47;2;248;Yunaska Island;x
1207;0;2;240;north sea;x
1208;48;2;236;atlantic ocean;x
...
3477;1;40;236;Lake Erie;x
3478;2;40;240;Lake Ontario;x
3479;3;40;244;Lake Winnipeg;x

What I need to do is print each line to a seperate unique .txt file.

The filename of each file must be in a particular format based on the contents of each line, for example "1 - Guadeloupe.txt" for the first file.

The contents of every file should be the same and is simply two lines:
trade_goods = timber
life_rating = 15

This needs to be accomplished using GNU command line tools such as sed and gawk. I am new to this.

I appreciate any help anybody can give me. Thank you.

Last edited by radoulov; 07-25-2011 at 08:59 AM.. Reason: Code tags, please!
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

To parse through the file and print output using awk or sed script

suppose if u have a file like that Hen ABCCSGSGSGJJJJK 15 Cock ABCCSGGGSGIJJJL 15 * * * * * * : * * * . * * * : Hen CFCDFCSDFCDERTF 30 Cock CHCDFCSDHCDEGFI 30 * . * * * * * * * : * * :* : : . The output shud be where there is : and . It shud... (4 Replies)
Discussion started by: cdfd123
4 Replies

2. Shell Programming and Scripting

awk/shell script to print each line to a file

Dear People, My query is: have a file, which looks likes this: 10 20 30 40 50 1 2 3 4 5 100 200 300 400 500 what i need is: "PRINT EACH LINE TO AN UNIQUE FILE" desired output: file 1 10 20 30 40 50 file 2 1 2 3 4 5 (3 Replies)
Discussion started by: saint2006
3 Replies

3. Shell Programming and Scripting

awk script: print line number n of another file

Hi, I wrote an awk script to analyse file A. I call the script with files A and B. File A has lines like: 000000033100001 000000036100001 000000039100001 The first 9 characters are interpreted as a line number; for each line number found I want to output this line number of file B. ... (13 Replies)
Discussion started by: kpg
13 Replies

4. Shell Programming and Scripting

extract nth line of all files and print in output file on separate lines.

Hello UNIX experts, I have 124 text files in a directory. I want to extract the 45678th line of all the files sequentialy by file names. The extracted lines should be printed in the output file on seperate lines. e.g. The input Files are one.txt, two.txt, three.txt, four.txt The cat of four... (1 Reply)
Discussion started by: yogeshkumkar
1 Replies

5. Shell Programming and Scripting

Passing parameter in sed or awk commands to print for the specific line in a file

Hi, I am trying to print a specific line in a file through sed or awk. The line number will be passed as a parameter from the previous step. My code looks as below. TEMP3=`sed -n '$TEMP2p' $FILEPATH/Log.txt` $TEMP2, I am getting from the previous step which is a numerical value(eg:3). ... (2 Replies)
Discussion started by: satyasrin82
2 Replies

6. Shell Programming and Scripting

awk print header as text from separate file with getline

I would like to print the output beginning with a header from a seperate file like this: awk 'BEGIN{FS="_";print ((getline < "header.txt")>0)} { if (! ($0 ~ /EL/ ) print }" input.txtWhat am i doing wrong? (4 Replies)
Discussion started by: sdf
4 Replies

7. Programming

Read text from file and print each character in separate line

performing this code to read from file and print each character in separate line works well with ASCII encoded text void preprocess_file (FILE *fp) { int cc; for (;;) { cc = getc (fp); if (cc == EOF) break; printf ("%c\n", cc); } } int main(int... (1 Reply)
Discussion started by: khaled79
1 Replies

8. UNIX for Dummies Questions & Answers

Split Every Line In Txt Into Separate Txt File, Named Same As The Line

Hi All Is there a way to export every line into new txt file where by the title of each txt output are same as the line ? I have this txt files containing names: Kandra Vanhooser Rhona Menefee Reynaldo Hutt Houston Rafferty Charmaine Lord Albertine Poucher Juana Maes Mitch Lobel... (2 Replies)
Discussion started by: Nexeu
2 Replies

9. UNIX for Beginners Questions & Answers

Output to file print as single line, not separate line

example of problem: when I echo "$e" >> /home/cogiz/file.txt result prints to file as:AA BB CC I need it to save to file as this:AA BB CC I know it's probably something really simple but any help would be greatly appreciated. Thank You. Cogiz (7 Replies)
Discussion started by: cogiz
7 Replies

10. Shell Programming and Scripting

awk to print line is values between two fields in separate file

I am trying to use awk to find all the $3 values in file2 that are between $2 and $3 in file1. If a value in $3 of file2 is between the file1 fields then it is printed along with the $6 value in file1. Both file1 and file2 are tab-delimited as well as the desired output. If there is nothing to... (4 Replies)
Discussion started by: cmccabe
4 Replies
ISO_8859-8(7)						     Linux Programmer's Manual						     ISO_8859-8(7)

NAME
iso_8859-8 - ISO 8859-8 character set encoded in octal, decimal, and hexadecimal DESCRIPTION
The ISO 8859 standard includes several 8-bit extensions to the ASCII character set (also known as ISO 646-IRV). ISO 8859-8, or "ISO Hebrew" encodes the characters used in Modern Hebrew (or Ivrit). Neither short vowels nor diacritical marks are included, and Yiddish is not provided for. ISO 8859 alphabets The full set of ISO 8859 alphabets includes: ISO 8859-1 West European languages (Latin-1) ISO 8859-2 Central and East European languages (Latin-2) ISO 8859-3 Southeast European and miscellaneous languages (Latin-3) ISO 8859-4 Scandinavian/Baltic languages (Latin-4) ISO 8859-5 Latin/Cyrillic ISO 8859-6 Latin/Arabic ISO 8859-7 Latin/Greek ISO 8859-8 Latin/Hebrew ISO 8859-9 Latin-1 modification for Turkish (Latin-5) ISO 8859-10 Lappish/Nordic/Eskimo languages (Latin-6) ISO 8859-11 Latin/Thai ISO 8859-13 Baltic Rim languages (Latin-7) ISO 8859-14 Celtic (Latin-8) ISO 8859-15 West European languages (Latin-9) ISO 8859-16 Romanian (Latin-10) ISO 8859-8 characters The following table displays the characters in ISO 8859-8, which are printable and unlisted in the ascii(7) manual page. The fourth column will only show the proper glyphs in an environment configured for ISO 8859-8. Oct Dec Hex Char Description -------------------------------------------------------------------- 240 160 A0 NO-BREAK SPACE 242 162 A2 c CENT SIGN 243 163 A3 L POUND SIGN 244 164 A4 EUR CURRENCY SIGN 245 165 A5 Y YEN SIGN 246 166 A6 BROKEN BAR 247 167 A7 S SECTION SIGN 250 168 A8 DIAERESIS 251 169 A9 (C) COPYRIGHT SIGN 252 170 AA a MULTIPLICATION SIGN 253 171 AB << LEFT-POINTING DOUBLE ANGLE QUOTATION MARK 254 172 AC ~ NOT SIGN 255 173 AD SOFT HYPHEN 256 174 AE (_) REGISTERED SIGN 257 175 AF MACRON 260 176 B0 o DEGREE SIGN 261 177 B1 +- PLUS-MINUS SIGN 262 178 B2 2 SUPERSCRIPT TWO 263 179 B3 3 SUPERSCRIPT THREE 264 180 B4 ACUTE ACCENT 265 181 B5 u MICRO SIGN 266 182 B6 9| PILCROW SIGN 267 183 B7 . MIDDLE DOT 270 184 B8 CEDILLA 271 185 B9 1 SUPERSCRIPT ONE 272 186 BA o DIVISION SIGN 273 187 BB >> RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK 274 188 BC OE VULGAR FRACTION ONE QUARTER 275 189 BD oe VULGAR FRACTION ONE HALF 276 190 BE VULGAR FRACTION THREE QUARTERS 337 223 DF B DOUBLE LOW LINE 340 224 E0 a HEBREW LETTER ALEF 341 225 E1 a HEBREW LETTER BET 342 226 E2 a HEBREW LETTER GIMEL 343 227 E3 a HEBREW LETTER DALET 344 228 E4 a HEBREW LETTER HE 345 229 E5 a HEBREW LETTER VAV 346 230 E6 ae HEBREW LETTER ZAYIN 347 231 E7 c HEBREW LETTER HET 350 232 E8 e HEBREW LETTER TET 351 233 E9 e HEBREW LETTER YOD 352 234 EA e HEBREW LETTER FINAL KAF 353 235 EB e HEBREW LETTER KAF 354 236 EC i HEBREW LETTER LAMED 355 237 ED i HEBREW LETTER FINAL MEM 356 238 EE i HEBREW LETTER MEM 357 239 EF i HEBREW LETTER FINAL NUN 360 240 F0 o HEBREW LETTER NUN 361 241 F1 n HEBREW LETTER SAMEKH 362 242 F2 o HEBREW LETTER AYIN 363 243 F3 o HEBREW LETTER FINAL PE 364 244 F4 o HEBREW LETTER PE 365 245 F5 o HEBREW LETTER FINAL TSADI 366 246 F6 o HEBREW LETTER TSADI 367 247 F7 -:- HEBREW LETTER QOF 370 248 F8 o HEBREW LETTER RESH 371 249 F9 u HEBREW LETTER SHIN 372 250 FA u HEBREW LETTER TAV 375 253 FD y LEFT-TO-RIGHT MARK 376 254 FE b RIGHT-TO-LEFT MARK NOTES
ISO 8859-8 was also known as ISO-IR-138. SEE ALSO
ascii(7) COLOPHON
This page is part of release 3.53 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 2010-09-20 ISO_8859-8(7)
All times are GMT -4. The time now is 05:38 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy