Sponsored Content
Top Forums Shell Programming and Scripting Help with extracting words from fixed length files Post 302459786 by bds052189 on Tuesday 5th of October 2010 11:11:18 AM
Old 10-05-2010
one more question...say the file actually looks like this...
Code:
HDR2010072600300405505100726 00300405505 customer name etc
LBJ FREEWAY DALLAS 
TELEGRAPH 751 HI
AR727612419 201007262010082520100823ABC
TELE EXGT401000300405505
DHL
HDR2010072600300405505100726 00300405505 customer name etc
LBJ FREEWAY DALLAS 
TELEGRAPH 751 HI
AR727612419 201007262010082520100823ABC
TELE EXGT401000300405505
DHL

There are multiple HDR lines and the customer name comes after the account that i need to extract?

Thanks

Last edited by Franklin52; 10-06-2010 at 03:33 AM.. Reason: Please use code tags!
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

creating a fixed length output from a variable length input

Is there a command that sets a variable length? I have a input of a variable length field but my output for that field needs to be set to 32 char. Is there such a command? I am on a sun box running ksh Thanks (2 Replies)
Discussion started by: r1500
2 Replies

2. Shell Programming and Scripting

sort on fixed length files

Hi How to sort a fixed length file on a given char range and just display the duplicates. I did search for man sort to find any option but could find any.,something similar to cut -c 1-5,25-35. I have alternate way of doing this by using combination of cut,awk. but this creates extra temp... (6 Replies)
Discussion started by: sach_in
6 Replies

3. Shell Programming and Scripting

Awk with fixed length files

Hi Unix Champs, I want to awk on a fixed length file. Instead if the file was a delimited file, then I could have used -F and then could have easily done manipulation on the fields. How do i do the same in case of fixed length file? Thanks in Advance. Regards. (7 Replies)
Discussion started by: c2b2
7 Replies

4. Shell Programming and Scripting

Join two fixed length Files in Unix

Hi, Can we join two fixed length files in Unix using JOIN command? Is there any other command to accomplish the same? Thanks, G.Harikrishnan (6 Replies)
Discussion started by: gharikrishnan
6 Replies

5. Shell Programming and Scripting

Awk - Working with fixed length files

OK I am somewhat new to UNIX programming please see what you can do to help. I have a flat file that is a fixed length file containing different records based on the 1st character of each line. The 1st number at the beginning of the line is the record number, in this case it's record #1. I... (3 Replies)
Discussion started by: ambroze
3 Replies

6. UNIX for Dummies Questions & Answers

What the command to find out the record length of a fixed length file?

I want to find out the record length of a fixed length file? I forgot the command. Any body know? (9 Replies)
Discussion started by: tranq01
9 Replies

7. Shell Programming and Scripting

Make variable length record a fixed length

Very, very new to unix scripting and have a unique situation. I have a file of records that contain 3 records types: (H)eader Records (D)etail Records (T)railer Records The Detail records are 82 bytes in length which is perfect. The Header and Trailer records sometimes are 82 bytes in... (3 Replies)
Discussion started by: jclanc8
3 Replies

8. Shell Programming and Scripting

changing a variable length text to a fixed length

Hi, Can anyone help with a effective solution ? I need to change a variable length text field (between 1 - 18 characters) to a fixed length text of 18 characters with the unused portion, at the end, filled with spaces. The text field is actually field 10 of a .csv file however I could cut... (7 Replies)
Discussion started by: dc18
7 Replies

9. UNIX for Dummies Questions & Answers

Fixed length file extracting values in columns

How do I extract values in a few columns in a row of a fixed length file? If there are 8 columns and I need to extract values of 2nd,4th and 6 th columns, how do i do that? I used cut command, this I used only for one column. How do I do it more than one column? The below command will give... (1 Reply)
Discussion started by: princetd001
1 Replies

10. Shell Programming and Scripting

Extracting fixed length number from a text file

Hi, I have a text file with sample records as CASE ID: 20170218881083 Original presentment record for ARN not found for Re-presentment I want to extract the 23 digit number from this file. I thought of using grep but initially couldn't extract the required number. However, after... (16 Replies)
Discussion started by: dsid
16 Replies
sem_wait(3C)						   Standard C Library Functions 					      sem_wait(3C)

NAME
sem_wait, sem_trywait - acquire or wait for a semaphore SYNOPSIS
#include <semaphore.h> int sem_wait(sem_t *sem); int sem_trywait(sem_t *sem); DESCRIPTION
The sem_wait() function locks the semaphore referenced by sem by performing a semaphore lock operation on that semaphore. If the semaphore value is currently zero, then the calling thread will not return from the call to sem_wait() until it either locks the semaphore or the call is interrupted by a signal. The sem_trywait() function locks the semaphore referenced by sem only if the semaphore is currently not locked; that is, if the semaphore value is currently positive. Otherwise, it does not lock the semaphore. Upon successful return, the state of the semaphore is locked and remains locked until the sem_post(3C) function is executed and returns successfully. The sem_wait() function is interruptible by the delivery of a signal. RETURN VALUES
The sem_wait() and sem_trywait() functions return 0 if the calling process successfully performed the semaphore lock operation on the sem- aphore designated by sem. If the call was unsuccessful, the state of the semaphore is unchanged, and the function returns -1 and sets errno to indicate the error. ERRORS
The sem_wait() and sem_trywait() functions will fail if: EINVAL The sem function does not refer to a valid semaphore. ENOSYS The sem_wait() and sem_trywait() functions are not supported by the system. The sem_trywait() function will fail if: EAGAIN The semaphore was already locked, so it cannot be immediately locked by the sem_trywait() operation. The sem_wait() and sem_trywait() functions may fail if: EDEADLK A deadlock condition was detected; that is, two separate processes are waiting for an available resource to be released via a semaphore "held" by the other process. EINTR A signal interrupted this function. USAGE
Realtime applications may encounter priority inversion when using semaphores. The problem occurs when a high priority thread "locks" (that is, waits on) a semaphore that is about to be "unlocked" (that is, posted) by a low priority thread, but the low priority thread is pre- empted by a medium priority thread. This scenario leads to priority inversion; a high priority thread is blocked by lower priority threads for an unlimited period of time. During system design, realtime programmers must take into account the possibility of this kind of priority inversion. They can deal with it in a number of ways, such as by having critical sections that are guarded by semaphores execute at a high priority, so that a thread cannot be preempted while executing in its critical section. EXAMPLES
Example 1 The customer waiting-line in a bank may be analogous to the synchronization scheme of a semaphore utilizing sem_wait() and sem_trywait(): #include <errno.h> #define TELLERS 10 sem_t bank_line; /* semaphore */ int banking_hours(), deposit_withdrawal; void *customer(), do_business(), skip_banking_today(); thread_t tid; ... sem_init(&bank_line,TRUE,TELLERS); /* 10 tellers available */ while(banking_hours()) thr_create(NULL, NULL, customer, (void *)deposit_withdrawal, THREAD_NEW_LWP, &tid); ... void * customer(deposit_withdrawal) void *deposit_withdrawal; { int this_customer, in_a_hurry = 50; this_customer = rand() % 100; if (this_customer == in_a_hurry) { if (sem_trywait(&bank_line) != 0) if (errno == EAGAIN) { /* no teller available */ skip_banking_today(this_customer); return; } /*else go immediately to available teller & decrement bank_line*/ } else sem_wait(&bank_line); /* wait for next teller, then proceed, and decrement bank_line */ do_business((int *)deposit_withdrawal); sem_getvalue(&bank_line,&num_tellers); sem_post(&bank_line); /* increment bank_line; this_customer's teller is now available */ } ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Interface Stability |Committed | +-----------------------------+-----------------------------+ |MT-Level |MT-Safe | +-----------------------------+-----------------------------+ |Standard |See standards(5). | +-----------------------------+-----------------------------+ SEE ALSO
sem_post(3C), attributes(5), standards(5) SunOS 5.11 5 Feb 2008 sem_wait(3C)
All times are GMT -4. The time now is 02:30 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy