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

NAME
armscii-8 - Armenian Character Set encoded in octal, decimal, and hexadecimal DESCRIPTION
The Armenian Standard Code for Information Interchange, 8-bit coded character set. ARMSCII-8 Characters The following table displays the characters in ARMSCII-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 armscii-8. Oct Dec Hex Char Description -------------------------------------------------------------------- 240 160 a0 NO-BREAK SPACE 242 162 a2 ARMENIAN SMALL LIGATURE ECH YIWN 243 163 a3 ARMENIAN FULL STOP 244 164 a4 ) RIGHT PARENTHESIS 245 165 a5 ( LEFT PARENTHESIS 246 166 a6 >> RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK 247 167 a7 << LEFT-POINTING DOUBLE ANGLE QUOTATION MARK 250 168 a8 -- EM DASH 251 169 a9 . FULL STOP 252 170 aa ARMENIAN COMMA 253 171 ab , COMMA 254 172 ac - HYPHEN-MINUS 255 173 ad ARMENIAN HYPHEN 256 174 ae HORIZONTAL ELLIPSIS 257 175 af ARMENIAN EXCLAMATION MARK 260 176 b0 ARMENIAN EMPHASIS MARK 261 177 b1 ARMENIAN QUESTION MARK 262 178 b2 ARMENIAN CAPITAL LETTER AYB 263 179 b3 ARMENIAN SMALL LETTER AYB 264 180 b4 ARMENIAN CAPITAL LETTER BEN 265 181 b5 ARMENIAN SMALL LETTER BEN 266 182 b6 ARMENIAN CAPITAL LETTER GIM 267 183 b7 ARMENIAN SMALL LETTER GIM 270 184 b8 ARMENIAN CAPITAL LETTER DA 271 185 b9 ARMENIAN SMALL LETTER DA 272 186 ba ARMENIAN CAPITAL LETTER ECH 273 187 bb ARMENIAN SMALL LETTER ECH 274 188 bc ARMENIAN CAPITAL LETTER ZA 275 189 bd ARMENIAN SMALL LETTER ZA 276 190 be ARMENIAN CAPITAL LETTER EH 277 191 bf ARMENIAN SMALL LETTER EH 300 192 c0 ARMENIAN CAPITAL LETTER ET 301 193 c1 ARMENIAN SMALL LETTER ET 302 194 c2 ARMENIAN CAPITAL LETTER TO 303 195 c3 ARMENIAN SMALL LETTER TO 304 196 c4 ARMENIAN CAPITAL LETTER ZHE 305 197 c5 ARMENIAN SMALL LETTER ZHE 306 198 c6 ARMENIAN CAPITAL LETTER INI 307 199 c7 ARMENIAN SMALL LETTER INI 310 200 c8 ARMENIAN CAPITAL LETTER LIWN 311 201 c9 ARMENIAN SMALL LETTER LIWN 312 202 ca ARMENIAN CAPITAL LETTER XEH 313 203 cb ARMENIAN SMALL LETTER XEH 314 204 cc ARMENIAN CAPITAL LETTER CA 315 205 cd ARMENIAN SMALL LETTER CA 316 206 ce ARMENIAN CAPITAL LETTER KEN 317 207 cf ARMENIAN SMALL LETTER KEN 320 208 d0 ARMENIAN CAPITAL LETTER HO 321 209 d1 ARMENIAN SMALL LETTER HO 322 210 d2 ARMENIAN CAPITAL LETTER JA 323 211 d3 ARMENIAN SMALL LETTER JA 324 212 d4 ARMENIAN CAPITAL LETTER GHAD 325 213 d5 ARMENIAN SMALL LETTER GHAD 326 214 d6 ARMENIAN CAPITAL LETTER CHEH 327 215 d7 ARMENIAN SMALL LETTER CHEH 330 216 d8 ARMENIAN CAPITAL LETTER MEN 331 217 d9 ARMENIAN SMALL LETTER MEN 332 218 da ARMENIAN CAPITAL LETTER YI 333 219 db ARMENIAN SMALL LETTER YI 334 219 dc ARMENIAN CAPITAL LETTER NOW 335 220 dd ARMENIAN SMALL LETTER NOW 336 221 de ARMENIAN CAPITAL LETTER SHA 337 222 df ARMENIAN SMALL LETTER SHA 340 223 e0 ARMENIAN CAPITAL LETTER VO 341 224 e1 ARMENIAN SMALL LETTER VO 342 225 e2 ARMENIAN CAPITAL LETTER CHA 343 226 e3 ARMENIAN SMALL LETTER CHA 344 227 e4 ARMENIAN CAPITAL LETTER PEH 345 228 e5 ARMENIAN SMALL LETTER PEH 346 229 e6 ARMENIAN CAPITAL LETTER JHEH 347 230 e7 ARMENIAN SMALL LETTER JHEH 350 231 e8 ARMENIAN CAPITAL LETTER RA 351 232 e9 ARMENIAN SMALL LETTER RA 352 233 ea ARMENIAN CAPITAL LETTER SEH 353 234 eb ARMENIAN SMALL LETTER SEH 354 235 ec ARMENIAN CAPITAL LETTER VEW 355 236 ed ARMENIAN SMALL LETTER VEW 356 237 ee ARMENIAN CAPITAL LETTER TIWN 357 238 ef ARMENIAN SMALL LETTER TIWN 360 239 f0 ARMENIAN CAPITAL LETTER REH 361 240 f1 ARMENIAN SMALL LETTER REH 362 241 f2 ARMENIAN CAPITAL LETTER CO 363 242 f3 ARMENIAN SMALL LETTER CO 364 243 f4 ARMENIAN CAPITAL LETTER YIWN 365 244 f5 ARMENIAN SMALL LETTER YIWN 366 245 f6 ARMENIAN CAPITAL LETTER PIWR 367 246 f7 ARMENIAN SMALL LETTER PIWR 370 247 f8 ARMENIAN CAPITAL LETTER KEH 371 248 f9 ARMENIAN SMALL LETTER KEH 372 249 fa ARMENIAN CAPITAL LETTER OH 373 250 fb ARMENIAN SMALL LETTER OH 374 251 fc ARMENIAN CAPITAL LETTER FEH 375 252 fd ARMENIAN SMALL LETTER FEH 376 253 fe ARMENIAN APOSTROPHE SEE ALSO
ascii(7) COLOPHON
This page is part of release 3.25 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-01-21 ARMSCII-8(7)
All times are GMT -4. The time now is 01:03 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy