Sponsored Content
Top Forums Shell Programming and Scripting delete repeated strings (tags) in a line and concatenate corresponding words Post 302469741 by mjomba on Monday 8th of November 2010 03:48:09 AM
Old 11-08-2010
delete repeated strings (tags) in a line and concatenate corresponding words

Hello friends!

Each line of my input file has this format:
word<TAB>tag1<blankspace>lemma<TAB>tag2<blankspace>lemma ... <TAB>tag3<blankspace>lemma

Of this file I need to eliminate all the repeated tags (of the same word) in a line, as in the example here below, but conserving both (all) the lemmata related to that tag, by concatenating them with a “|” separator.

My INPUT (sample):
abecedaria ADJ abecedarius ADJ:abl abecedarius N:abl abecedaria N:abl abecedarium N:acc abecedaria N:acc abecedarium N:nom abecedaria N:nom abecedarium N:voc abecedaria N:voc abecedarium
abecedariabus N:abl abecedaria N:dat abecedaria
abhorruerimus V:IND abhorreo V:IND abhorresco V:SUB abhorreo V:SUB abhorresco
abhorrueritis V:IND abhorreo V:IND abhorresco V:SUB abhorreo V:SUB abhorresco
abhorruero V:IND abhorreo V:IND abhorresco

Desired OUTPUT:
abecedaria ADJ abecedarius ADJ:abl abecedarius N:abl abecedaria|abecedarium N:acc abecedaria|abecedarium N:nom abecedaria|abecedarium N:voc abecedaria|abecedarium
abecedariabus N:abl abecedaria N:dat abecedaria
abhorruerimus V:IND abhorreo|abhorresco V:SUB abhorreo|abhorresco
abhorrueritis V:IND abhorreo |abhorresco V:SUB abhorreo|abhorresco
abhorruero V:IND abhorreo|abhorresco

Very gratefull to anyone who can help me!
mjomba from Tanzania
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to concatenate two strings or several strings into one string in B-shell?

like connect "summer" and "winter" to "summerwinter"? Can anybody help me? thanks a lot. (2 Replies)
Discussion started by: fontana
2 Replies

2. Shell Programming and Scripting

Concatenate strings line by line

Hi, I have a noob question . Can someone help me how to concatenate line by line using this variables? var1: Apple| Banana| var2: Red Yellow then how can I concatenate both line by line? in which the result would be: Apple|Red Banana|Yellow just to generate a row result i was... (6 Replies)
Discussion started by: hagdanan
6 Replies

3. Shell Programming and Scripting

How can i delete some words in every line in a file

Hi, I need help to delete a few words in every line in my file. This is how the file look like: VDC DQ 14900098,,,,157426.06849776753,786693.2919373367 10273032,,,,157525.49445429695,776574.5546672409 VDC DG ,10273033,,3er55,,149565.57096061576,801778.9379555212 AS174 892562,,,,, ... (2 Replies)
Discussion started by: andy_s
2 Replies

4. Shell Programming and Scripting

To Delete the repeated occurances and print in same line by appending values

Hi All, I am trying to work on below text a b c 1 a b c 2 a b c 3 x y z 6 x y z 44 a b c 89 Need to delete the occurances and get in single line like below: a b c 1 2 3 89 x y z 6 44 89 Please help me i am new into unix scripting ..... ---------- Post updated at 03:00... (8 Replies)
Discussion started by: shaliniyadav
8 Replies

5. Shell Programming and Scripting

Delete 2 strings from 1 line with sed?

Hi guys, I wonder if it's possible to search for a line containing 2 strings and delete that line and perhaps replace the source file with already deleted line(s). What I mean is something like this: sourcefile.txt line1: something 122344 somethin2 24334 45554676 line2: another something... (6 Replies)
Discussion started by: netrom
6 Replies

6. Shell Programming and Scripting

Find repeated word and take sum of the second field to it ,for all the repeated words in awk

Hi below is the input file, i need to find repeated words and sum up the values of it which is second field from the repeated work.Im trying but getting no where close to it.Kindly give me a hint on how to go about it Input fruits,apple,20,fruits,mango,20,veg,carrot,12,veg,raddish,30... (11 Replies)
Discussion started by: 100bees
11 Replies

7. UNIX for Dummies Questions & Answers

Delete lines according to a key words in that line

HI, I have a file A like this: c 1 length 14432 width 3434 temp 34 c 2 length 3343 width 0923 height 9383 hm 902 temp34 c 3 length 938 height 982 hm 9292 temp 23 ... (2 Replies)
Discussion started by: the_simpsons
2 Replies

8. Shell Programming and Scripting

USING sed to remove multiple strings/words from a line

Hi I use sed comnand to remove occurance of one workd from a line. However I need to removed occurance of dufferent words in ne line. Original-1 Hi this is the END of my begining Comand sed s/"END"/"start"/g Output-1 Hi this is the start of my beginig But I have more... (9 Replies)
Discussion started by: mnassiri
9 Replies

9. Shell Programming and Scripting

Delete duplicate strings in a line

Hi, i need help to remove duplicates in my file. The problem is i need to delete one duplicate for each line only. the input file as follows and it is not tab delimited:- The output need to remove 2nd word (in red) that duplicate with 1st word (in blue). Other duplicates should remained... (12 Replies)
Discussion started by: redse171
12 Replies

10. Shell Programming and Scripting

Remove repeated letter words

Hi, I have this text file with these words and I need help with removing words with repeated letter from these lines. 1 ama 5 bib 29 bob 2 bub 5 civic 2 dad 10 deed 1 denned 335 did 1 eeee 1 eeeee 2 eke 8... (4 Replies)
Discussion started by: crepe6
4 Replies
libtnfctl(3TNF) 					       TNF Library Functions						   libtnfctl(3TNF)

NAME
libtnfctl - library for TNF probe control in a process or the kernel SYNOPSIS
cc [ flag ... ] file ... -ltnfctl [ library ... ] #include <tnf/tnfctl.h> DESCRIPTION
The libtnfctl library provides an API to control TNF ("Trace Normal Form") probes within a process or the kernel. See tracing(3TNF) for an overview of the Solaris tracing architecture. The client of libtnfctl controls probes in one of four modes: internal mode The target is the controlling process itself; that is, the client controls its own probes. direct mode The target is a separate process; a client can either exec(2) a program or attach to a running process for probe control. The libtnfctl library uses proc(4) on the target process for probe and process control in this mode, and additionally pro- vides basic process control features. indirect mode The target is a separate process, but the controlling process is already using proc(4) to control the target, and hence libtnfctl cannot use those interfaces directly. Use this mode to control probes from within a debugger. In this mode, the client must provide a set of functions that libtnfctl can use to query and update the target process. kernel mode The target is the Solaris kernel. A process is controlled "externally" if it is being controlled in either direct mode or indirect mode. Alternatively, a process is con- trolled "internally" when it uses internal mode to control its own probes. There can be only one client at a time doing probe control on a given process. Therefore, it is not possible for a process to be controlled internally while it is being controlled externally. It is also not possible to have a process controlled by multiple external processes. Similarly, there can be only one process at a time doing kernel probe control. Note, however, that while a given target may only be con- trolled by one libtnfctl client, a single client may control an arbitrary number of targets. That is, it is possible for a process to simultaneously control its own probes, probes in other processes, and probes in the kernel. The following tables denotes the modes applicable to all libtnfctl interfaces (INT = internal mode; D = direct mode; IND = indirect mode; K = kernel mode). These interfaces create handles in the specified modes: tnfctl_internal_open() INT tnfctl_exec_open() D tnfctl_pid_open() D tnfctl_indirect_open() IND tnfctl_kernel_open() K These interfaces are used with the specified modes: tnfctl_continue() D tnfctl_probe_connect() INT D IND tnfctl_probe_disconnect_all () INT D IND tnfctl_trace_attrs_get() INT D IND K tnfctl_buffer_alloc() INT D IND K tnfctl_register_funcs() INT D IND K tnfctl_probe_apply() INT D IND K tnfctl_probe_apply_ids() INT D IND K tnfctl_probe_state_get () INT D IND K tnfctl_probe_enable() INT D IND K tnfctl_probe_disable() INT D IND K tnfctl_probe_trace() INT D IND K tnfctl_probe_untrace() INT D IND K tnfctl_check_libs() INT D IND K tnfctl_close() INT D IND K tnfctl_strerror() INT D IND K tnfctl_buffer_dealloc() K tnfctl_trace_state_set() K tnfctl_filter_state_set() K tnfctl_filter_list_get() K tnfctl_filter_list_add() K tnfctl_filter_list_delete() K When using libtnfctl, the first task is to create a handle for controlling probes. The tnfctl_internal_open() function creates an internal mode handle for controlling probes in the same process, as described above. The tnfctl_pid_open() and tnfctl_exec_open() functions create handles in direct mode. The tnfctl_indirect_open() function creates an indirect mode handle, and the tnfctl_kernel_open() function creates a kernel mode handle. A handle is required for use in nearly all other libtnfctl functions. The tnfctl_close() function releases the resources associated with a handle. The tnfctl_continue() function is used in direct mode to resume execution of the target process. The tnfctl_buffer_alloc() function allocates a trace file or, in kernel mode, a trace buffer. The tnfctl_probe_apply() and tnfctl_probe_apply_ids() functions call a specified function for each probe or for a designated set of probes. The tnfctl_register_funcs() function registers functions to be called whenever new probes are seen or probes have disappeared, providing an opportunity to do one-time processing for each probe. The tnfctl_check_libs() function is used primarily in indirect mode to check whether any new probes have appeared, that is, they have been made available by dlopen(3C), or have disappeared, that is, they have disassociated from the process by dlclose(3C). The tnfctl_probe_enable() and tnfctl_probe_disable() functions control whether the probe, when hit, will be ignored. The tnfctl_probe_trace() and tnfctl_probe_untrace() functions control whether an enabled probe, when hit, will cause an entry to be made in the trace file. The tnfctl_probe_connect() and tnfctl_probe_disconnect_all() functions control which functions, if any, are called when an enabled probe is hit. The tnfctl_probe_state_get() function returns information about the status of a probe, such as whether it is currently enabled. The tnfctl_trace_attrs_get() function returns information about the tracing session, such as the size of the trace buffer or trace file. The tnfctl_strerror() function maps a tnfctl error code to a string, for reporting purposes. The remaining functions apply only to kernel mode. The tnfctl_trace_state_set() function controls the master switch for kernel tracing. See prex(1) for more details. The tnfctl_filter_state_set(), tnfctl_filter_list_get(), tnfctl_filter_list_add(), and tnfctl_filter_list_delete() functions allow a set of processes to be specified for which probes will not be ignored when hit. This prevents kernel activity caused by uninteresting processes from cluttering up the kernel's trace buffer. The tnfctl_buffer_dealloc() function deallocates the kernel's internal trace buffer. RETURN VALUES
Upon successful completion, these functions returnTNFCTL_ERR_NONE. ERRORS
The error codes for libtnfctl are: TNFCTL_ERR_ACCES Permission denied. TNFCTL_ERR_NOTARGET The target process completed. TNFCTL_ERR_ALLOCFAIL A memory allocation failure occurred. TNFCTL_ERR_INTERNAL An internal error occurred. TNFCTL_ERR_SIZETOOSMALL The requested trace size is too small. TNFCTL_ERR_SIZETOOBIG The requested trace size is too big. TNFCTL_ERR_BADARG Bad input argument. TNFCTL_ERR_NOTDYNAMIC The target is not a dynamic executable. TNFCTL_ERR_NOLIBTNFPROBE libtnfprobe.so not linked in target. TNFCTL_ERR_BUFBROKEN Tracing is broken in the target. TNFCTL_ERR_BUFEXISTS A buffer already exists. TNFCTL_ERR_NOBUF No buffer exists. TNFCTL_ERR_BADDEALLOC Cannot deallocate buffer. TNFCTL_ERR_NOPROCESS No such target process exists. TNFCTL_ERR_FILENOTFOUND File not found. TNFCTL_ERR_BUSY Cannot attach to process or kernel because it is already tracing. TNFCTL_ERR_INVALIDPROBE Probe no longer valid. TNFCTL_ERR_USR1 Error code reserved for user. TNFCTL_ERR_USR2 Error code reserved for user. TNFCTL_ERR_USR3 Error code reserved for user. TNFCTL_ERR_USR4 Error code reserved for user. TNFCTL_ERR_USR5 Error code reserved for user. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWtnfc | +-----------------------------+-----------------------------+ |MT Level |MT-Safe with exceptions | +-----------------------------+-----------------------------+ SEE ALSO
prex(1), exec(2), dlclose(3C), dlopen(3C), TNF_PROBE(3TNF), tnfctl_buffer_alloc(3TNF), tnfctl_buffer_dealloc(3TNF), tnfctl_check_libs(3TNF), tnfctl_close(3TNF), tnfctl_continue(3TNF), tnfctl_internal_open(3TNF), tnfctl_exec_open(3TNF), tnfctl_fil- ter_list_add(3TNF), tnfctl_filter_list_delete(3TNF), tnfctl_filter_list_get(3TNF), tnfctl_filter_state_set(3TNF), tnfctl_ker- nel_open(3TNF), tnfctl_pid_open(3TNF), tnfctl_probe_apply(3TNF), tnfctl_probe_apply_ids(3TNF), tnfctl_probe_connect(3TNF), tnfctl_probe_disable(3TNF), tnfctl_probe_enable(3TNF), tnfctl_probe_state_get(3TNF), tnfctl_probe_trace(3TNF), tnfctl_probe_untrace(3TNF), tnfctl_indirect_open(3TNF), tnfctl_register_funcs(3TNF), tnfctl_strerror(3TNF), tnfctl_trace_attrs_get(3TNF), tnfctl_trace_state_set(3TNF), libtnfctl(3LIB), proc(4), attributes(5) Linker and Libraries Guide NOTES
This API is MT-Safe. Multiple threads may concurrently operate on independent tnfctl handles, which is the typical behavior expected. The libtnfctl library does not support multiple threads operating on the same tnfctl handle. If this is desired, it is the client's responsibility to implement locking to ensure that two threads that use the same tnfctl handle are not simultaneously in a libtnfctl interface. SunOS 5.10 1 Mar 2004 libtnfctl(3TNF)
All times are GMT -4. The time now is 05:35 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy