Sponsored Content
Top Forums Shell Programming and Scripting Get distinct value in bash between two string Post 302967267 by cterra on Monday 22nd of February 2016 04:35:03 AM
Old 02-22-2016
Get distinct value in bash between two string

Sorry for my english i am french

So i am receiving from a script this prompt :
Code:
tabular;critical;mirroring;DG INTlocaldg VOLUME appears
tabular;critical;mirroring;DG INTlocaldg VOLUME bh3vm
tabular;critical;mirroring;DG INTlocaldg VOLUME dev
tabular;critical;mirroring;DG INTlocaldg VOLUME earsdev
tabular;critical;mirroring;DG INTlocaldg VOLUME earslivraison
tabular;critical;mirroring;DG INTlocaldg VOLUME earsrct
tabular;critical;mirroring;DG INTlocaldg VOLUME ed
tabular;critical;mirroring;DG INTlocaldg VOLUME eng
tabular;critical;mirroring;DG INTlocaldg VOLUME home
tabular;critical;mirroring;DG INTlocaldg VOLUME home_Ctibco6
tabular;critical;mirroring;DG INTlocaldg VOLUME home_adapter
tabular;critical;mirroring;DG INTlocaldg VOLUME icf
tabular;critical;mirroring;DG INTlocaldg VOLUME investigation
tabular;critical;mirroring;DG INTlocaldg VOLUME isa_dev
tabular;critical;mirroring;DG INTlocaldg VOLUME isa_rct
tabular;critical;mirroring;DG INTlocaldg VOLUME isa_share
tabular;critical;mirroring;DG INTlocaldg VOLUME livraison
tabular;critical;mirroring;DG INTlocaldg VOLUME mq
tabular;critical;mirroring;DG INTlocaldg VOLUME mqlog
tabular;critical;mirroring;DG INTlocaldg VOLUME mqprod
tabular;critical;mirroring;DG INTlocaldg VOLUME mqvar
tabular;critical;mirroring;DG INTlocaldg VOLUME netbackup
tabular;critical;mirroring;DG INTlocaldg VOLUME od-home
tabular;critical;mirroring;DG INTlocaldg VOLUME oracle
tabular;critical;mirroring;DG INTlocaldg VOLUME oradb
tabular;critical;mirroring;DG INTlocaldg VOLUME ov
tabular;critical;mirroring;DG INTlocaldg VOLUME rct
tabular;critical;mirroring;DG INTlocaldg VOLUME rc3
tabular;critical;mirroring;DG INTlocaldg VOLUME sar
tabular;critical;mirroring;DG INTlocaldg VOLUME soa
tabular;critical;mirroring;DG INTlocaldg VOLUME tibbh3
tabular;critical;tibco;DG INTlocaldg VOLUME tibco
tabular;critical;tibco;DG INTlocaldg VOLUME tibco_dev6
tabular;critical;tibco;DG INTlocaldg VOLUME tibco_rc2
tabular;critical;tibco;DG INTlocaldg VOLUME tibcobh3
tabular;critical;mirroring;DG INTlocaldg VOLUME tws00
tabular;critical;mirroring;DG INTlocaldg VOLUME unix
tabular;critical;was;DG INTlocaldg VOLUME was6
tabular;critical;was;DG INTlocaldg VOLUME was6dev
tabular;critical;was;DG INTlocaldg VOLUME was6devcells
tabular;critical;was;DG INTlocaldg VOLUME was6devlogs
tabular;critical;was;DG INTlocaldg VOLUME was6devproduct
tabular;critical;was;DG INTlocaldg VOLUME was6distrib
tabular;critical;was;DG INTlocaldg VOLUME was6rct
tabular;critical;was;DG INTlocaldg VOLUME was6rctcells
tabular;critical;was;DG INTlocaldg VOLUME was6rctlogs
tabular;critical;was;DG INTlocaldg VOLUME was6rctproduct
tabular;critical;was;DG INTlocaldg VOLUME was6share

I need to get the list of my error type
Basicly i need to get distinct value between 'critical'; and the third ';'
was
tibco
mirroring

in this exemple, but i can have lot of more.

Can i do this with one command, or should i put all in one table and compare every value ?
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Bash string replace

Bash shell. I'm trying to filter a string taken from user input. I can replace one word at a time. This method supports regex, so is it possible to replace various words at a time? STRING="Hello World! word1 word2"; FILTERED=${STRING/word1|word2/}; # Not working: replace 2 or more words ??? ... (10 Replies)
Discussion started by: limmer
10 Replies

2. Shell Programming and Scripting

String comparison using bash

I have a program to create a directory if not present. Here is the program. FYI: Directory name format: YYYY_MM_DD #!/bin/bash date=`date +%Y_%m_%d` presence=$(ls -lrt /TS_File/ | grep "$date" | awk '{print $9}') if then mkdir /TS_File/$date else echo "Unable to Create... (5 Replies)
Discussion started by: nthiruvenkatam
5 Replies

3. Shell Programming and Scripting

Get the distinct string from file.

my question is , i want to get the distinct email address from the file which contains: <Email address>|<file name> /tmp/test.log petercs@yahoo.com|sf1.pdf sandycs@yahoo.com|sf2.pdf davidcs@yahoo.com|sf3.pdf davidcs@yahoo.com|sf4.pdf i want to get the result like: petercs@yahoo.com... (5 Replies)
Discussion started by: bearonweb
5 Replies

4. Shell Programming and Scripting

bash string manipulation

Hello guys, here is my problem: I got a shell script which is called by an external piece of software, the external software is not under my control. The software passes data as an argument to my script like ./bla.sh 'service;1234567890;ok;hostname;some text here' I need to pass the... (3 Replies)
Discussion started by: snoogie
3 Replies

5. Shell Programming and Scripting

Bash string manipulation

In my script I'm retrieving a parameter through an API call. I need to trim some things out of the result so I can use it as a parameter to pass to another process. I've got it working but it's pretty kludgy and I'm hoping someone can help me with a better way. This is the code that retrieves... (2 Replies)
Discussion started by: withanh
2 Replies

6. Shell Programming and Scripting

How do a distinct from a file using sort uniq in bash?

I have an output file .dat. From this file i have to do a distinct of the ID using the sort uniq command in bash script. How can i do it? i found : sort -u ${FILEOUT_DAT} but i don't think is my solution because the id isn't specified.. is there other solution? (7 Replies)
Discussion started by: punticci
7 Replies

7. Shell Programming and Scripting

Bash Integers/String

Hy friends, I am newbie to bash scripting, can anyone explain how b=${a/23/BB} # Substitute "BB" for "23". this line converts "b" into string and and "d" into Integer. Thanks in advance (4 Replies)
Discussion started by: Qazi
4 Replies

8. Shell Programming and Scripting

Bash: Getting first digit of a string

If i'm given a string like "abc-def-1.2.3", how would I return "1"? I'm new to scripting and got stumped on this problem. Thanks in advance! (7 Replies)
Discussion started by: atsim
7 Replies

9. UNIX for Beginners Questions & Answers

Escape bash-special character in a bash string

Hi, I am new in bash scripting. In my work, I provide support to several users and when I connect to their computers I use the same admin and password, so I am trying to create a script that will only ask me for the IP address and then connect to the computer without having me to type the user... (5 Replies)
Discussion started by: arcoa05
5 Replies
CRITICAL_ENTER(9)					   BSD Kernel Developer's Manual					 CRITICAL_ENTER(9)

NAME
critical_enter, critical_exit -- enter and exit a critical region SYNOPSIS
#include <sys/param.h> #include <sys/systm.h> void critical_enter(void); void critical_exit(void); DESCRIPTION
These functions are used to prevent preemption in a critical region of code. All that is guaranteed is that the thread currently executing on a CPU will not be preempted. Specifically, a thread in a critical region will not migrate to another CPU while it is in a critical region. The current CPU may still trigger faults and exceptions during a critical section; however, these faults are usually fatal. The critical_enter() and critical_exit() functions manage a per-thread counter to handle nested critical sections. If a thread is made runnable that would normally preempt the current thread while the current thread is in a critical section, then the preemption will be deferred until the current thread exits the outermost critical section. Note that these functions are not required to provide any inter-CPU synchronization, data protection, or memory ordering guarantees and thus should not be used to protect shared data structures. These functions should be used with care as an infinite loop within a critical region will deadlock the CPU. Also, they should not be inter- locked with operations on mutexes, sx locks, semaphores, or other synchronization primitives. One exception to this is that spin mutexes include a critical section, so in certain cases critical sections may be interlocked with spin mutexes. HISTORY
These functions were introduced in FreeBSD 5.0. BSD
October 5, 2005 BSD
All times are GMT -4. The time now is 03:00 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy