Sponsored Content
Top Forums Shell Programming and Scripting Find lines containing two strings Post 302438265 by dazdseg on Monday 19th of July 2010 08:14:33 AM
Old 07-19-2010
out_file lets say consist of ur SEFGWN;BVABCFSDFBDEF
Code:
sed '/ABC/!d;/DEF/!d' out_file
awk '/ABC.*DEF/' out_file

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Find lines with space between strings

Hello all, I am having trouble with setting up a regular expression used with egrep. My script reads an input file a line at a time. I would like the egrep command to search for the following pattern: server name at the beginning of the line, then one or more spaces, and then a pound sign. ... (5 Replies)
Discussion started by: Galt
5 Replies

2. Shell Programming and Scripting

using AWK see the upper lines and lower lines of the strings??

Hi experts, You cool guys already given me the awk script below- awk '/9366109380/,printed==5 { ++printed; print; }' 2008-09-14.0.log Morever, i have one more things- when i awk 9366109380, i can also see the Upper 3 lines as well as below 5 lines of that string. Line 1.... (3 Replies)
Discussion started by: thepurple
3 Replies

3. Shell Programming and Scripting

How to find the lines which do not have certain strings

Hi, guys. I have one question: How can I search the lines in a file which do not have certain string in it. For example, the file is called shadow, the contents of it is below: **************************** ... brownj:SFSM$DFAAA2313:0:0:50:7 hynesp:MNBADF$23$adfd:0:0:50:7... (2 Replies)
Discussion started by: daikeyang
2 Replies

4. Shell Programming and Scripting

Grep and delete lines except the lines with strings

Hi I am writing a script which should read a file and search for certain strings 'approved' or 'removed' and retain only those lines that contain the above strings. Ex: file name 'test' test: approved package waiting for approval package disapproved package removed package approved... (14 Replies)
Discussion started by: vj8436
14 Replies

5. Shell Programming and Scripting

Removing empty lines(space) between two lines containing strings

Hi, Please provide shell script to Remove empty lines(space) between two lines containing strings in a file. Input File : A1/EXT "BAP_BSC6/07B/00" 844 090602 1605 RXOCF-465 PDTR11 1 SITE ON BATTERY A2/EXT... (3 Replies)
Discussion started by: sudhakaryadav
3 Replies

6. UNIX for Dummies Questions & Answers

grep command to find multiple strings in multiple lines in a file.

I want to search files (basically .cc files) in /xx folder and subfolders. Those files (*.cc files) must contain #include "header.h" AND x() function. I am writing it another way to make it clear, I wanna list of *.cc files that have 'header.h' & 'x()'. They must have two strings, header.h... (2 Replies)
Discussion started by: ritikaSharma
2 Replies

7. Shell Programming and Scripting

Awk - find string, search lines below string for other strings

What's the easiest way to search a file for a specific string and then look for other instances after that? I want to search for all Virtual Hosts and print out the Server Name and Document Root (if it has that info), while discarding the rest of the info. Basically my file looks like this: ...... (6 Replies)
Discussion started by: Mbohmer
6 Replies

8. Shell Programming and Scripting

Delete lines in file containing duplicate strings, keeping longer strings

The question is not as simple as the title... I have a file, it looks like this <string name="string1">RZ-LED</string> <string name="string2">2.0</string> <string name="string2">Version 2.0</string> <string name="string3">BP</string> I would like to check for duplicate entries of... (11 Replies)
Discussion started by: raidzero
11 Replies

9. Shell Programming and Scripting

How to find lines in a .txt contains the strings I want

I have a .txt contains a lot of lines. Now I want to write a shell script to find out all the lines which contain the strings I want, and print these lines. For example: A.txt when you post any code you can easily do this highlighting your code and then click you should do a Google... (6 Replies)
Discussion started by: Henryyy
6 Replies

10. Solaris

How to find multiple strings on different lines in file?

Hello, I have spent considerable amount of time breaking my head on this and reached out here. here is the back ground. OS - Solaris 10 There are two strings '<Orin>sop' and '<Dup>two' which I wanted to look for in a file without the quotes on different lines and ONLY if both strings are... (5 Replies)
Discussion started by: keithTait309875
5 Replies
Slurm API(3)					 Slurm reservation information reporting functions				      Slurm API(3)

NAME
slurm_load_reservations, slurm_free_reservation_info_msg, slurm_print_reservation_info, slurm_sprint_reservation_info, slurm_print_reserva- tion_info_msg - Slurm reservation information reporting functions SYNTAX
#include <stdio.h> #include <slurm/slurm.h> int slurm_load_reservations ( time_t update_time, reserve_info_msg_t **reservation_info_msg_pptr ); void slurm_free_reservation_info_msg ( reserve_info_msg_t *reservation_info_msg_ptr ); void slurm_print_reservation_info ( FILE *out_file, reserve_info_t *reservation_ptr, int one_liner ); char * slurm_sprint_reservation_info ( reserve_info_t *reservation_ptr, int one_liner ); void slurm_print_reservation_info_msg ( FILE *out_file, reserve_info_msg_t *reservation_info_msg_ptr, int one_liner ); ARGUMENTS
one_liner Print one record per line if non-zero. out_file Specifies the file to print data to. reservation_info_msg_pptr Specifies the double pointer to the structure to be created and filled with the time of the last reservation update, a record count, and detailed information about each reservation. Detailed reservation information is written to fixed sized records and includes: reservation name, time limits, access restrictions, etc. See slurm.h for full details on the data structure's contents. reservation_info_msg_ptr Specifies the pointer to the structure created by slurm_load_reservations. update_time For all of the following informational calls, if update_time is equal to or greater than the last time changes where made to that information, new information is not returned. Otherwise all the configuration. job, node, or reservation records are returned. DESCRIPTION
slurm_load_reservations Returns a reserve_info_msg_t that contains an update time, record count, and array of reservation_table records for all reservations. slurm_free_reservation_info_msg Release the storage generated by the slurm_load_reservations function. slurm_print_reservation_info Prints the contents of the data structure describing one of the reservation records from the data loaded by the slurm_load_reservations function. slurm_sprint_reservation_info Prints the sames info as slurm_print_reservation_info, but prints to a string that must be freed by the caller, rather than printing to a file. slurm_print_reservation_info_msg Prints the contents of the data structure describing all reservation records loaded by the slurm_load_reservations function. RETURN VALUE
On success, zero is returned. On error, -1 is returned, and Slurm error code is set appropriately. ERRORS
SLURM_NO_CHANGE_IN_DATA Data has not changed since update_time. SLURM_PROTOCOL_VERSION_ERROR Protocol version has changed, re-link your code. SLURM_PROTOCOL_SOCKET_IMPL_TIMEOUT Timeout in communicating with SLURM controller. EXAMPLE
#include <stdio.h> #include <stdlib.h> #include <slurm/slurm.h> #include <slurm/slurm_errno.h> int main (int argc, char *argv[]) { int i; reserve_info_msg_t *res_info_ptr = NULL; reserve_info_t *res_ptr; /* get and dump all reservation information */ if (slurm_load_reservations((time_t)NULL, &res_info_ptr)) { slurm_perror ("slurm_load_reservations error"); exit (1); } /* The easy way to print... */ slurm_print_reservation_info_msg(stdout, res_info_ptr, 0); /* A harder way.. */ for (i = 0; i < res_info_ptr->record_count; i++) { res_ptr = &res_info_ptr->reservation_array[i]; slurm_print_reservation_info(stdout, res_ptr, 0); } /* The hardest way. */ printf("reservations updated at %lx, records=%d ", res_info_ptr->last_update, res_info_ptr->record_count); for (i = 0; i < res_info_ptr->record_count; i++) { printf ("reservationName=%s Nodes=%s ", res_info_ptr->reservation_array[i].name, res_info_ptr->reservation_array[i].node_list ); } slurm_free_reservation_info_msg (res_info_ptr); return 0; } NOTES
These functions are included in the libslurm library, which must be linked to your process for use (e.g. "cc -lslurm myprog.c"). The slurm_hostlist_ functions can be used to convert SLURM node list expressions into a collection of individual node names. COPYING
Copyright (C) 2002-2006 The Regents of the University of California. Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). CODE-OCEC-09-009. All rights reserved. This file is part of SLURM, a resource management program. For details, see <http://www.schedmd.com/slurmdocs/>. SLURM is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. SLURM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. SEE ALSO
scontrol(1), sinfo(1), squeue(1), slurm_hostlist_create(3), slurm_hostlist_shift(3), slurm_hostlist_destroy(3), slurm_get_errno(3), slurm_load_node(3), slurm_perror(3), slurm_strerror(3) David Bremer January 2009 Slurm API(3)
All times are GMT -4. The time now is 02:09 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy