Sponsored Content
Top Forums Shell Programming and Scripting Issues in reading file using 'awk' Post 302781347 by Don Cragun on Saturday 16th of March 2013 08:50:09 AM
Old 03-16-2013
Quote:
Originally Posted by emily
Hi,
Thanks for the reply,
Yes, it is the actual name of the log that I posted at [1].
ummm, I guess it the the symbol for the starting of the next line. Cos the content was not enough to come on the single line.

Besides, using the command on the terminal give the proper 'jobNo' on the same qcd12_status.log file.

emily
I am guessing that we have a small language barrier in this discussion.

The output that you said you were getting when you run the command manually has a leading space that the awk script you showed us would not produce.
The output that you said you were getting when you run the command manually also contains text from the continuation line in your log file that your awk script does not handle.

When I run the awk script you provided with the input data you provided, the output produced is:
Code:
57,331,333,336,348,2-3,11,28,45,49,67-68,80,82,87,102-104,107-108,111-112,114,117-118,123-125,127-132,134,139,148-157,159-161,169-172,174,179-180\

not:
Code:
 57,331,333,336,348,2-3,11,28,45,49,67-68,80,82,87,102-104,107-108,111-112,114,117-118,123-125,127-132,134,139,148-157,159-161,169-172,174,179-180,182-185,200,202,204,208-210,219,226,236,238,245,251,253-257,262,265,271,280,288,308,330,353,355,375,377,381,385,387

But, we are using awk after the command that produced the input file is long gone. Since your script is running crab to produce the file being read by awk asynchronously in the background while awk is running in the foreground, there is a good chance that awk will hit end of file before crab writes anything into the file. If this happens, obviously jobNo will be set to an empty string.

If you get rid of the ampersand (&) at the end of the crab command line and if crab does not split long "List of jobs" lines with backslashes (\) and follow them with the continuation lines that you showed in your 1st message in this thread, everything should work as you expect it to work.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Reading large file, awk and cut

Hello all, I have 2 files, the first (indexFile1) contains start offset and length for each record inside the second file. The second file can be very large, each actual record start offset and length is defined by the entry in indexFile1. Since there are no records separators wc-l returns 0 for... (1 Reply)
Discussion started by: gio001
1 Replies

2. Shell Programming and Scripting

Using awk to when reading a file to search and output to file

Hi, I am not sure if this will work or not. I am getting a syntax error. I am reading fileA, using an acct number field trying to see if it exists in fileB and output to new file. Can anyone tell me if what I am doing will work or should I attempt it another way? Thanks. exec < "${fileA}... (4 Replies)
Discussion started by: ski
4 Replies

3. Shell Programming and Scripting

Reading a file several times with awk

Hi everyone, I was wondering if it's possible to read a file ("file2" in my example) more than once. In this example I want to print file2 entirely for each lines of file1: awk -F$'\t' '{ print $0 while ((getline < "file2") > 0) { print "\t"$0 } }' file1 It... (4 Replies)
Discussion started by: anthony.cros
4 Replies

4. Shell Programming and Scripting

Issues with Reading Line by line from a file

I am trying to read a host name one at a time from a file which has a list of hostnames and do rsh and print . its not looping through the entire file. its breaking out after the first entry. If i comment out the rsh then it loops through file #!/bin/ksh filename="/tmp/hostnames"; while read -r... (11 Replies)
Discussion started by: SMunje
11 Replies

5. Shell Programming and Scripting

awk- reading input file twice

Hello, I've been trying to come up with a solution for the following problem; I have an input file with two columns and I want to print as an output the first column without any changes but for the second column, I want to divide it by its last value. Example input: 1 9 2 10 3 11 4 12 5... (14 Replies)
Discussion started by: acsg
14 Replies

6. Shell Programming and Scripting

awk file reading doubt

Hi, Using this trivial code, I am trying to insert/paste the single column data of a file into the second column (field 2) of a multi-column text file. awk 'FNR==NR {a=$0; next} {$1=$1 OFS a}1' single-column-file multi-column-file Lets consider the single-column-file as 'f2' and multi-column... (1 Reply)
Discussion started by: royalibrahim
1 Replies

7. Shell Programming and Scripting

reading file awk or while

While read line query !!! Folks, I am working on a file which has entries as follows. I am using while read line to generate desired output as follows. filename1: Name : sdt2156157_ID NOS : 4567 NOS : 2348 Name : sdt2156158_ID NOS : 4987 NOS :... (3 Replies)
Discussion started by: dynamax
3 Replies

8. Shell Programming and Scripting

awk issue while reading from file in while do

Hi Friends, I am trying to scan line by line using awk and pull the values and pass it in variables and then will use the variables but doesn't work. Please see below for details. #more dbtest.sh ---------------------------------- #!/bin/bash . $HOME/.bash_profile while read line do... (6 Replies)
Discussion started by: narunice
6 Replies

9. Shell Programming and Scripting

Reading data from file using awk

I have a file as below. It contains two data sets separated by >. I want to pipe each data set to another program called psxy. How can I get the different records Have started doing as follows but it only passes the first data set awk 'BEGIN {RS=">"};{print $0}' p.dat cat p.dat... (12 Replies)
Discussion started by: kristinu
12 Replies

10. Shell Programming and Scripting

Awk: File Checking Issues with 9 multiple file

Hi, I have 9 files which are generated dynamically & if there is a some condition which doesn't meet the criteria then file is not created or is of zero size. so further i am unable to consolidate the files based on following code 1 awk -F, -v ptime="201407" 'FNR==1... (3 Replies)
Discussion started by: siramitsharma
3 Replies
iconv_8859-1(5) 					Standards, Environments, and Macros					   iconv_8859-1(5)

NAME
iconv_8859-1 - code set conversion tables for ISO 8859-1 (Latin 1) DESCRIPTION
The following code set conversions are supported: +--------------------------------------------------------------------+ | Code Set Conversions Supported | +--------------+--------+--------------+--------+--------------------+ | Code |Symbol |Target Code |Symbol | Target Output | +--------------+--------+--------------+--------+--------------------+ |ISO 8859-1 |8859 |ISO 646 |646 | 7 bit ASCII | +--------------+--------+--------------+--------+--------------------+ |ISO 8859-1 |8859 |ISO 646de |646de | German | +--------------+--------+--------------+--------+--------------------+ |ISO 8859-1 |8859 |ISO 646da |646da | Danish | +--------------+--------+--------------+--------+--------------------+ |ISO 8859-1 |8859 |ISO 646en |646en | English ASCII | +--------------+--------+--------------+--------+--------------------+ |ISO 8859-1 |8859 |ISO 646es |646es | Spanish | +--------------+--------+--------------+--------+--------------------+ |ISO 8859-1 |8859 |ISO 646fr |646fr | French | +--------------+--------+--------------+--------+--------------------+ |ISO 8859-1 |8859 |ISO 646it |646it | Italian | +--------------+--------+--------------+--------+--------------------+ |ISO 8859-1 |8859 |ISO 646sv |646sv | Swedish | +--------------+--------+--------------+--------+--------------------+ CONVERSIONS
The conversions are performed according to the following tables. All values in the tables are given in octal. ISO 8859-1 to ISO 646 (7-bit ASCII) For the conversion of ISO 8859-1 to ISO 646, all characters not in the following table are mapped unchanged. Converted to Underscore '_' (137) --------------------------------- 200 201 202 203 204 205 206 207 210 211 212 213 214 215 216 217 220 221 222 223 224 225 226 227 230 231 232 233 234 235 236 237 240 241 242 243 244 245 246 247 250 251 252 253 254 255 256 257 260 261 262 263 264 265 266 267 270 271 272 273 274 275 276 277 300 301 302 303 304 305 306 307 310 311 312 313 314 315 316 317 320 321 322 323 324 325 326 327 330 331 332 333 334 335 336 337 340 341 342 343 344 345 346 347 350 351 352 353 354 355 356 357 360 361 362 363 364 365 366 367 370 371 372 373 374 375 376 377 ISO 8859-1 to ISO 646de (GERMAN) For the conversion of ISO 8859-1 to ISO 646de, all characters not in the following tables are mapped unchanged. +-----------------------------------------------------------------+ | | Conversions|Performed | | | ISO 8859-1 | ISO 646de | ISO 8859-1 | ISO 646de | |247 | 100 |337 |176 | |304 | 133 |344 |173 | |326 | 134 |366 |174 | |334 | 135 |374 |175 | +---------------+----------------+----------------+---------------+ Converted to Underscore '_' (137) --------------------------------- 100 133 134 135 173 174 175 176 200 201 202 203 204 205 206 207 210 211 212 213 214 215 216 217 220 221 222 223 224 225 226 227 230 231 232 233 234 235 236 237 240 241 242 243 244 245 246 250 251 252 253 254 255 256 257 260 261 262 263 264 265 266 267 270 271 272 273 274 275 276 277 300 301 302 303 305 306 307 310 311 312 313 314 315 316 317 320 321 322 323 324 325 327 330 331 332 333 335 336 337 340 341 342 343 345 346 347 350 351 352 353 354 355 356 357 360 361 362 363 364 365 367 370 371 372 373 375 376 377 ISO 8859-1 to ISO 646da (DANISH) For the conversion of ISO 8859-1 to ISO 646da, all characters not in the following tables are mapped unchanged. +-----------------------------------------------------------------+ | Conversions Performed | +---------------+----------------+----------------+---------------+ | ISO 8859-1 | ISO 646da | ISO 8859-1 | ISO | +---------------+----------------+----------------+---------------+ |646da | | | | +---------------+----------------+----------------+---------------+ |305 | 135 |345 |175 | +---------------+----------------+----------------+---------------+ |306 | 133 |346 |173 | +---------------+----------------+----------------+---------------+ |330 | 134 |370 |174 | +---------------+----------------+----------------+---------------+ Converted to Underscore '_' (137) --------------------------------- 133 134 135 173 174 175 200 201 202 203 204 205 206 207 210 211 212 213 214 215 216 217 220 221 222 223 224 225 226 227 230 231 232 233 234 235 236 237 240 241 242 243 244 245 246 247 250 251 252 253 254 255 256 257 260 261 262 263 264 265 266 267 270 271 272 273 274 275 276 277 300 301 302 303 304 307 310 311 312 313 314 315 316 317 320 321 322 323 324 325 326 327 331 332 333 334 335 336 337 340 341 342 343 344 347 350 351 352 353 354 355 356 357 360 361 362 363 364 365 366 367 371 372 373 374 376 377 ISO 8859-1 to ISO 646en (ENGLISH ASCII) For the conversion of ISO 8859-1 to ISO 646en, all characters not in the following tables are mapped unchanged. +-----------------------------------------------------------+ | Conversions Performed | +-----------------------------+-----------------------------+ | ISO 8859-1 | ISO 646en | +-----------------------------+-----------------------------+ |243 |043 | +-----------------------------+-----------------------------+ Converted to Underscore '_' (137) --------------------------------- 043 200 201 202 203 204 205 206 207 210 211 212 213 214 215 216 217 220 221 222 223 224 225 226 227 230 231 232 233 234 235 236 237 240 241 242 244 245 246 247 250 251 252 253 254 255 256 257 260 261 262 263 264 265 266 267 270 271 272 273 274 275 276 277 300 301 302 303 304 305 306 307 310 311 312 313 314 315 316 317 320 321 322 323 324 325 326 327 330 331 332 333 334 335 336 337 340 341 342 343 344 345 346 347 350 351 352 353 354 355 356 357 360 361 362 363 364 365 366 367 370 371 372 373 374 375 376 377 ISO 8859-1 to ISO 646fr (FRENCH) For the conversion of ISO 8859-1 to ISO 646fr, all characters not in the following tables are mapped unchanged. +-----------------------------------------------------------------+ | | Conversions|Performed | | | ISO 8859-1 | ISO 646fr | ISO 8859-1 | ISO 646fr | |243 | 043 |347 |134 | |247 | 135 |350 |175 | |250 | 176 |351 |173 | |260 | 133 |371 |174 | |340 | 100 | | | +---------------+----------------+----------------+---------------+ Converted to Underscore '_' (137) --------------------------------- 043 100 133 134 135 173 174 175 176 200 201 202 203 204 205 206 207 210 211 212 213 214 215 216 217 220 221 222 223 224 225 226 227 230 231 232 233 234 235 236 237 240 241 242 244 245 246 251 252 253 254 255 256 257 261 262 263 264 265 266 267 270 271 272 273 274 275 276 277 300 301 302 303 304 305 306 307 310 311 312 313 314 315 316 317 320 321 322 323 324 325 326 327 330 331 332 333 334 335 336 337 341 342 343 344 345 346 352 353 354 355 356 357 360 361 362 363 364 365 366 367 370 372 373 374 375 376 377 ISO 8859-1 to ISO 646it (ITALIAN) For the conversion of ISO 8859-1 to ISO 646it, all characters not in the following tables are mapped unchanged. +-----------------------------------------------------------------+ | | Conversions|Performed | | | ISO 8859-1 | ISO 646it | ISO 8859-1 | ISO 646it | |243 | 043 |350 |175 | |247 | 100 |351 |135 | |260 | 133 |354 |176 | |340 | 173 |362 |174 | |347 | 134 |371 |140 | +---------------+----------------+----------------+---------------+ Converted to Underscore '_' (137) --------------------------------- 043 100 133 134 135 173 174 175 176 200 201 202 203 204 205 206 207 210 211 212 213 214 215 216 217 220 221 222 223 224 225 226 227 230 231 232 233 234 235 236 237 240 241 242 244 245 246 250 251 252 253 254 255 256 257 261 262 263 264 265 266 267 270 271 272 273 274 275 276 277 300 301 302 303 304 305 306 307 310 311 312 313 314 315 316 317 320 321 322 323 324 325 326 327 330 331 332 333 334 335 336 337 341 342 343 344 345 346 352 353 354 355 356 357 360 361 362 363 364 365 366 367 370 372 373 374 375 376 377 ISO 8859-1 to ISO 646es (SPANISH) For the conversion of ISO 8859-1 to ISO 646es, all characters not in the following tables are mapped unchanged. +-----------------------------------------------------------------+ | | Conversions|Performed | | | ISO 8859-1 | ISO 646es | ISO 8859-1 | ISO 646es | |241 | 133 |321 |134 | |247 | 100 |347 |175 | |260 | 173 |361 |174 | |277 | 135 | | | +---------------+----------------+----------------+---------------+ Converted to Underscore '_' (137) --------------------------------- 100 133 134 135 173 174 175 200 201 202 203 204 205 206 207 210 211 212 213 214 215 216 217 220 221 222 223 224 225 226 227 230 231 232 233 234 235 236 237 240 242 243 244 245 246 250 251 252 253 254 255 256 257 261 262 263 264 265 266 267 270 271 272 273 274 275 276 300 301 302 303 304 305 306 307 310 311 312 313 314 315 316 317 320 322 323 324 325 326 327 330 331 332 333 334 335 336 337 340 341 342 343 344 345 346 350 351 352 353 354 355 356 357 360 362 363 364 365 366 367 370 371 372 373 374 375 376 377 ISO 8859-1 to ISO 646sv (SWEDISH) For the conversion of ISO 8859-1 to ISO 646sv, all characters not in the following tables are mapped unchanged. +-----------------------------------------------------------------+ | | Conversions|Performed | | | ISO 8859-1 | ISO 646sv | ISO 8859-1 | ISO 646sv | |304 | 133 |344 |173 | |305 | 135 |345 |175 | |311 | 100 |351 |140 | |326 | 134 |366 |174 | |334 | 136 |374 |176 | +---------------+----------------+----------------+---------------+ Converted to Underscore '_' (137) --------------------------------- 100 133 134 135 136 140 173 174 175 176 200 201 202 203 204 205 206 207 210 211 212 213 214 215 216 217 220 221 222 223 224 225 226 227 230 231 232 233 234 235 236 237 240 241 242 243 244 245 246 247 250 251 252 253 254 255 256 257 260 261 262 263 264 265 266 267 270 271 272 273 274 275 276 277 300 301 302 303 306 307 310 312 313 314 315 316 317 320 321 322 323 324 325 327 330 331 332 333 335 336 337 340 341 342 343 346 347 350 352 353 354 355 356 357 360 361 362 363 364 365 367 370 371 372 373 375 376 377 FILES
/usr/lib/iconv/*.so conversion modules /usr/lib/iconv/*.t conversion tables /usr/lib/iconv/iconv_data list of conversions supported by conversion tables SEE ALSO
iconv(1), iconv(3C), iconv(5) SunOS 5.10 28 Apr 1997 iconv_8859-1(5)
All times are GMT -4. The time now is 08:12 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy