Sponsored Content
Top Forums Shell Programming and Scripting Get line number when matches a string Post 302391662 by malcomex999 on Tuesday 2nd of February 2010 06:21:12 AM
Old 02-02-2010
Code:
 awk '/^BAG/{print FNR ":" $0;next}{print}' infile

 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Select matches between line number and end of file?

Hi Guys/Gals, I have a log file that is updated once every few seconds and I am looking for a way to speed up one of my scripts. Basically what I am trying to do is grep through a text file from start to finish once. Then each subsequent grep starts at the last line of the previous grep to... (4 Replies)
Discussion started by: Jerrad
4 Replies

2. Shell Programming and Scripting

Need to find a string, check the next line, and if it matches certain criteria, replace it with a s

Hey Fellas. I am new to scripting. I have searched through the forums and found a lot of good info, but I can't seem to get any of it to work together. I am trying to find a particular sting in a file, and if the next string matches certain criteria, replace it with a string from a csv... (6 Replies)
Discussion started by: midniteslice
6 Replies

3. Shell Programming and Scripting

Help in printing n number of lines if a search string matches in a file

Hi I have below script which is used to grep specific errors and if error string matches send an email alert. Script is working fine , however , i wish to print next 10 lines of the string match to get the details of error in the email alert Current code:- #!/bin/bash tail -Fn0 --retry... (2 Replies)
Discussion started by: neha0785
2 Replies

4. Shell Programming and Scripting

Deleting double quoted string from a line when line number is variable

I need to remove double quoted strings from specific lines in a file. The specific line numbers are a variable. For example, line 5 of the file contains A B C "string" I want to remove "string". The following sed command works: sed '5 s/\"*\"//' $file If there are multiple... (2 Replies)
Discussion started by: rennatsb
2 Replies

5. Shell Programming and Scripting

Count number of pattern matches per line for all files in directory

I have a directory of files, each with a variable (though small) number of lines. I would like to go through each line in each file, and print the: -file name -line number -number of matches to the pattern /comp/ for each line. Two example files: cat... (4 Replies)
Discussion started by: pathunkathunk
4 Replies

6. Shell Programming and Scripting

Print entire line only if certain fixed character matches the string

Hi All, I have a file testarun.txt contains the below lines and i want to print the lines if the character positions 7-8 matches 01. 201401011111 201401022222 201402013333 201402024444 201403015555 201403026666 201404017777 201404028888 201405019999 201405020000 I am trying the... (4 Replies)
Discussion started by: Arunprasad
4 Replies

7. Shell Programming and Scripting

Print line if values in fields matches number and text

datafile: 2017-03-24 10:26:22.098566|5|'No Route for Sndr:RETEK RMS 00040 /ZZ Appl:PF Func:PD Txn:832 Group Cntr:None ISA CntlNr:None Ver:003050 '|'2'|'PFI'|'-'|'EAI_ED_DeleteAll'|'EAI_ED'|NULL|NULL|NULL|139050594|ActivityLog| 2017-03-27 02:50:02.028706|5|'No Route for... (7 Replies)
Discussion started by: SkySmart
7 Replies

8. Shell Programming and Scripting

Replace all string matches in file with unique random number

Hello Take this file... Test01 Ref test Version 01 Test02 Ref test Version 02 Test66 Ref test Version 66 Test99 Ref test Version 99 I want to substitute every occurrence of Test{2} with a unique random number, so for example, if I was using sed, substitution would be something... (1 Reply)
Discussion started by: funkman
1 Replies

9. UNIX for Beginners Questions & Answers

Replace matches string in each line with the arrayvalue in shell

I have a list of value , and need to replace that in my file. Eg: File1 tcname:fail tcname: Pass tcname:skipped File2: 01,02,03 Output: File 1 01:fail 02: Pass 03:Skipped (8 Replies)
Discussion started by: DevAakash
8 Replies
KNIFE-DATA-BAG(1)						    Chef Manual 						 KNIFE-DATA-BAG(1)

NAME
knife-data-bag - Store arbitrary data on a Chef Server SYNOPSIS
knife data bag sub-command (options) DESCRIPTION
Data bags are stores of arbitrary JSON data. Each data bag is a collection that may contain many items. Data Bag Items are indexed by the Chef Server and can be searched via knife-search(1). Data bags are available to all nodes configured by chef-client(8), and are therefore a convenient mechanism to store global information, such as lists of administrative accounts that should be configured on all hosts. DATA BAG SUB-COMMANDS CREATE
knife data bag create bag name [item id] (options) -s, --secret SECRET A secret key used to encrypt the data bag item. See encryption support below. --secret-file SECRET_FILE The path to a file containing the secret key to be used to encrypt the data bag item. If item id is given, creates a new, empty data bag item and opens it for editing in your editor. The data bag will be created if it does not exist. If item id is not given, the data bag will be created. DELETE
knife data bag delete bag name [item id] (options) Delete a data bag, or an item from a data bag. EDIT
knife data bag edit bag name item id (options) -s, --secret SECRET A secret key used to encrypt the data bag item. See encryption support below. --secret-file SECRET_FILE The path to a file containing the secret key to be used to encrypt the data bag item. Edit an item in a data bag. FROM FILE
knife data bag from file bag name file (options) knife data bag from file bag name file1 file2 file3 (options) knife data bag from file bag name folder (options) -s, --secret SECRET A secret key used to encrypt the data bag item. See encryption support below. --secret-file SECRET_FILE The path to a file containing the secret key to be used to encrypt the data bag item. Load a data bag item from a JSON file. If file is a relative or absolute path to the file, that file will be used. Otherwise, the file parameter is treated as the base name of a data bag file in a Chef repository, and knife will search for the file in ./data_bags/bag_name/file. For example knife data bag from file users dan.json would attempt to load the file ./data_bags/users/dan.json. LIST
knife data bag list (options) -w, --with-uri Show corresponding URIs Lists the data bags that exist on the Chef Server. SHOW
knife data bag show BAG [ITEM] (options) -s, --secret SECRET A secret key used to encrypt the data bag item. See encryption support below. --secret-file SECRET_FILE The path to a file containing the secret key to be used to encrypt the data bag item. Show a specific data bag or an item in a data bag. The output will be formatted according to the --format option. ENCRYPTION SUPPORT
Data Bag Items may be encrypted to keep their contents secret. This may be desireable when storing sensitive information such as database passwords, API keys, etc. Data Bag Item encryption uses the AES-256 CBC symmetric key algorithm. CAVEATS: Keys are not encrypted; only values are encrypted. The "id" of a Data Bag Item is not encrypted, since it is used by Chef Server to store the item in its database. For example, given the following data bag item: {"id": "important_passwords", "secret_password": "opensesame"} The key "secret_password" will be visible to an evesdropper, but the value "opensesame" will be protected. Both the key "id" and its value "important_passwords" will be visible to an evesdropper. Chef Server does not provide a secure mechanism for distributing encryption keys. SEE ALSO
knife-search(1) AUTHOR
Chef was written by Adam Jacob adam@opscode.com with many contributions from the community. DOCUMENTATION
This manual page was written by Joshua Timberman joshua@opscode.com. Permission is granted to copy, distribute and / or modify this docu- ment under the terms of the Apache 2.0 License. CHEF
Knife is distributed with Chef. http://wiki.opscode.com/display/chef/Home Chef 10.12.0 June 2012 KNIFE-DATA-BAG(1)
All times are GMT -4. The time now is 01:58 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy