Sponsored Content
Top Forums Shell Programming and Scripting Get output of multiple pattern match from first field to a file Post 302990456 by MadeInGermany on Thursday 26th of January 2017 12:59:37 PM
Old 01-26-2017
Code:
#!/bin/sh
pserver=""
while read server path
do
  if [ "$server" != "$pserver" ]; then
    exec 3>>"$server".out
    pserver=$server
  fi
  echo "$server $path" >&3
done < datafile.txt

If the input file is sorted, it can become more efficient
Code:
#!/bin/sh
pserver=""
sort -k1,1 datafile.txt |
while read server path
do
  if [ "$server" != "$pserver" ]; then
    exec 3>"$server".out
    pserver=$server
  fi
  echo "$server $path" >&3
done < datafile.txt

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Output Multiple Field from dataBase file

I am fairly new in unix I was wondering if anybody can help me out with this: I am trying to output to a file the following fields; Field1 Field2 Field4 From a database file dataBase1. this is how the file looks: dataBase1 TABLE DATA Example ================== Table ... (3 Replies)
Discussion started by: Dennz
3 Replies

2. Shell Programming and Scripting

how do i pattern match a field with awk?

hi, let's say $numbers = "324 350 587" an so on... what i'm trying to do is this: awk -v numbers="$numbers" '{if (numbers ~ /$2/) print $0, "bla bla"}' file # file looks like this: 214 ..... 215 ... 216 .... 250 ... 324 325 ... 350 something ... ... 587 ... (4 Replies)
Discussion started by: someone123
4 Replies

3. Shell Programming and Scripting

AWK: Pattern match between 2 files, then compare a field in file1 as > or < field in file2

First, thanks for the help in previous posts... couldn't have gotten where I am now without it! So here is what I have, I use AWK to match $1 and $2 as 1 string in file1 to $1 and $2 as 1 string in file2. Now I'm wondering if I can extend this AWK command to incorporate the following: If $1... (4 Replies)
Discussion started by: right_coaster
4 Replies

4. UNIX for Dummies Questions & Answers

Match pattern in a field, print pattern only instead of the entire field

Hi ! I have a tab-delimited file, file.tab: Column1 Column2 Column3 aaaaaaaaaa bbtomatoesbbbbbb cccccccccc ddddddddd eeeeappleseeeeeeeee ffffffffffffff ggggggggg hhhhhhtomatoeshhh iiiiiiiiiiiiiiii ... (18 Replies)
Discussion started by: lucasvs
18 Replies

5. Shell Programming and Scripting

Multiple pattern match and print the output in a single line

I need to match two patterns in a log file and need to get the next line of the one of the pattern (out of two patterns) that is matched, finally need to print these three values in a single line. Sample Log: 2013/06/11 14:29:04 <0999> (725102) Processing batch 02_1231324 2013/06/11... (4 Replies)
Discussion started by: rpm120
4 Replies

6. Shell Programming and Scripting

Match Pattern and print pattern and multiple lines into one line

Hello Experts , require help . See below output: File inputs ------------------------------------------ Server Host = mike id rl images allocated last updated density vimages expiration last read <------- STATUS ------->... (4 Replies)
Discussion started by: tigerhills
4 Replies

7. Shell Programming and Scripting

Remove multiple lines that match pattern

Not sure how I can accomplish this. I would like to remove all interfaces that have the commands I would like to see: switchport port-security, spanning-tree portfast. One line is no problem. interface FastEthernet0/8 spanning-tree portfast interface FastEthernet0/9 spanning-tree... (4 Replies)
Discussion started by: mrlayance
4 Replies

8. Shell Programming and Scripting

Command/script to match a field and print the next field of each line in a file.

Hello, I have a text file in the below format: Source Destination State Lag Status CQA02W2K12pl:D:\CAQA ... (10 Replies)
Discussion started by: pocodot
10 Replies

9. Shell Programming and Scripting

Removing multiple lines from input file, if multiple lines match a pattern.

GM, I have an issue at work, which requires a simple solution. But, after multiple attempts, I have not been able to hit on the code needed. I am assuming that sed, awk or even perl could do what I need. I have an application that adds extra blank page feeds, for multiple reports, when... (7 Replies)
Discussion started by: jxfish2
7 Replies

10. UNIX for Beginners Questions & Answers

Modify text file if found multiple pattern match for every line.

Looking for help, i have input file like below and want to modify to expected output, if can without create additional file, hope can direct modify it. have 2 thing need do. 1st is adding a word (testplan generation off) after ! ! IPG: Tue Aug 07 14:31:17 2018 2nd is adding... (16 Replies)
Discussion started by: kttan
16 Replies
aecvsserver(1)															    aecvsserver(1)

NAME
aecvsserver - serve CVS client protocol against Aegis projects SYNOPSIS
aecvsserver server aecvsserver pserver aecvsserver -VERSion DESCRIPTION
The aecvsserver command is used to serve the CVS client protocol. The repository, of course, is stored within Aegis. The server works by retrieving file contents from locations within Aegis change sets and repositories. When necessary, appropriate aegis(1) commands are executed by the server to fulfill the requests. This code is still experimental. At the present time only a limited number of CVS commands are understood. If you would like to extend this code, contributions are welcome. The following commands are thought to work at this time: add, admin, checkout, commit, init, remove, update. server To use the server, you will need to set the following environment variables: CVSROOT=:ext:hostname/aegis CVS_RSH=ssh CVS_SERVER=aecvsserver pserver It is also possible to use aecvsserver as a cvs pserver, with all the usual caveats about how insecure this access method is, because it transmits the password almost in the clear. The root and modules are as above. MODULES
The CVS concept of modules is mapped onto Aegis concept of projects and changes. The special CVSROOT administrative module is simulated. Projects as Modules Each Aegis project appears to the CVS client as a module; the module's name is the same as the Aegis project's name. This type of module isn't immediately useful except for the cvs export command, or to perform a read-only cvs checkout command. You can't commit to a project-named module. This because Aegis requires all operations which would change the repository to be performed through a change set. It is theoretically possible to code aecvsserver to create a change (via aenc(1) and aedb(1) commands), then add the necessary files (via aenf(1) and aecp(1) commands), then build (via the aeb(1) command), then test (via the aet(1) command), and finally to end development of the change (via the aede(1) command). As the CVS protocol documentation says "The protocol makes it possible for updates to be atomic with respect to checkins; that is, if someone commits changes to several files in one cvs command, then an update by someone else would either get all the changes, or none of them. The current cvs server can't do this, but that isn't the protocol's fault." This code is yet to be written. Contributions welcome. The protocol, however, doesn't make it particularly easy, either. The semantics of the Modify request change depending on whether it is followed by the commit request or the update request. Changes as Modules Each Aegis change set also appears to the CVS client as a module; it's name is project.Cnumber. All cvs add commands, cvs remove com- mands, cvs update commands and cvs commit commands are performed against the change set, not directly to the baseline. It is necessary for the change set to already exist, and once you have run the cvs commit command, it will the be necessary to use the aede(1) command and the rest of the usual Aegis process. Once a change is no longer in the being developed state, it cannot be changed via aecvsserver(1) and you will need to create a new Aegis change set, and then cvs checkout a new client-side work area. Please note: if you are experimenting with the interface via cvs -d :fork:/aegis or similar, the work area you create must be outside the Aegis change set's development directory. CVSROOT The CVSROOT module's contents are synthesized from Aegis meta-data. You can't add or modify files in this module; you need to administer Aegis directly with aegis(1) commands. EXIT STATUS
The aecvsserver command will exit with a status of 1 on any error. The aecvsserver command will only exit with a status of 0 if there are no errors. ENVIRONMENT VARIABLES
See aegis(1) for a list of environment variables which may affect this command. See aepconf(5) for the project configuration file's project_specific field for how to set environment variables for all commands executed by Aegis. COPYRIGHT
aecvsserver version 4.24.3.D001 Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Peter Miller The aecvsserver program comes with ABSOLUTELY NO WARRANTY; for details use the 'aecvsserver -VERSion License' command. This is free soft- ware and you are welcome to redistribute it under certain conditions; for details use the 'aecvsserver -VERSion License' command. AUTHOR
Peter Miller E-Mail: millerp@canb.auug.org.au //* WWW: http://www.canb.auug.org.au/~millerp/ Reference Manual Aegis aecvsserver(1)
All times are GMT -4. The time now is 05:35 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy