Sponsored Content
Top Forums Shell Programming and Scripting Modify sections of the line in a file Post 302339187 by ryandegreat25 on Thursday 30th of July 2009 03:31:54 AM
Old 07-30-2009
Quote:
Originally Posted by ciba
Hi
I need to modify entire file starting from the 3 line. file looks like this
filename : exp

first line
second
1,"wes","est","ws"
1,"was","qwe","qwa"

also i have to replace the third content from 3 line by a counter . so the output should look like this:

first line
second
1,"wes","1","ws"
1,"was","2","qwa"

here 1, 2 is a type of incrementing counter ...

please help Smilie
please create new thread
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

How to modify a line in a file

Hello I have an input that looks like this: d:/bla1/bla2/bla3/bla1.txt d:/bla1/bla2/bla4/bla2.txt d:/bla1/bla2/bla5/bla1.txt d:/bla1/bla2/bla6/bla2.txt d:/bla1/bla2/bla7/bla1.txt and i need the output to looks like this: d:/bla1/bla2/bla3/bla1_bla3.txt... (5 Replies)
Discussion started by: RoadKill
5 Replies

2. Shell Programming and Scripting

How to modify the last line in the file.

Hi, I have data file which has header, data and trailer. The problem is that always the trailer is padded with the last line data. i want to split the trailer and bring it to next line i.e end of line. But i dont have any specific string to identify the trailer. Only way is that all data... (3 Replies)
Discussion started by: senthil_is
3 Replies

3. Shell Programming and Scripting

Modify Specific Line of a Text File

Given a text file, how do you add a line of text after a specific line number? I believe I would want to use "sed" but I am unsure of the syntax. Thank you. Mike (5 Replies)
Discussion started by: msb65
5 Replies

4. Shell Programming and Scripting

Need help to modify perl script: Text file with line and more than 1 space

Dear Friends, I am beginner in Perl and trying to find the problem in a script. Kindly help me to modify the script. My script is not giving the output for the last field and followed text (LA: Language English). Input file & script as follows: Input file: Thu Mar 19 2:34:14 EDT 2009 STC... (3 Replies)
Discussion started by: srsahu75
3 Replies

5. Shell Programming and Scripting

Help with a shell script to modify one line and copy the next 9 to same file

Hi everyone, the problem is quite simple, yet I can't find an easy solution using awk. I need to search for a string in $3, then if I find this string, copy the line,modify $3, and copy the next 9 lines to the same file. My problem is in the copying of the lines... Finding and modifying... (5 Replies)
Discussion started by: Teroc
5 Replies

6. Shell Programming and Scripting

Modify a file by another file: add new line and variable after string is found

hello, I have problem with writing/adjusting a shell script. I searched forum and unfortunately couldn't write scipt based on the information I found. I never wtire such so it's hard for me and I do need to modify one script immediately. case looks like: 1. 'file' that needs to be modified... (3 Replies)
Discussion started by: bipbip
3 Replies

7. Shell Programming and Scripting

Modify one line in a plain text file

Hi everyone, I want to know, if there is a way to modify one line in a text file with unix script, with out re-writing all the file. For example, i have this file: CONFIGURATION_1=XXXX CONFIGURATION_2=YYYY CONFIGURATION_3=ZZZZ supose i have a command or function "modify" that... (7 Replies)
Discussion started by: Xedrox
7 Replies

8. Shell Programming and Scripting

Extract certain sections of a line

I have a log that looks like below sc.mng_10_Err.20131020_000000.log:NCSSC_MNG_UP_PE_TO_BE : Failed to change dvc_trx_sts from PE to BE for srvtrx: 213323141427349 dvcsfx: 1 sc.mng_4_Err.20131020_000000.log:NCSSC_MNG_UP_PE_TO_BE : Failed to change dvc_trx_sts from PE to BE for srvtrx:... (6 Replies)
Discussion started by: senormarquez
6 Replies

9. Shell Programming and Scripting

Remove sections based on duplicate first line

Hi, I have a file with many sections in it. Each section is separated by a blank line. The first line of each section would determine if the section is duplicate or not. if the section is duplicate then remove the entire section from the file. below is the example of input and output.... (5 Replies)
Discussion started by: ahmedwaseem2000
5 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
SNMPUSM(1)							     Net-SNMP								SNMPUSM(1)

NAME
snmpusm - creates and maintains SNMPv3 users on a network entity SYNOPSIS
snmpusm [COMMON OPTIONS] create USER [CLONEFROM-USER] snmpusm [COMMON OPTIONS] delete USER snmpusm [COMMON OPTIONS] cloneFrom USER CLONEFROM-USER snmpusm [COMMON OPTIONS] [-Ca] [-Cx] passwd OLD-PASSPHRASE NEW-PASSPHRASE [USER] snmpusm [COMMON OPTIONS] <-Ca | -Cx> -Ck passwd OLD-KEY-OR-PASSPHRASE NEW-KEY-OR-PASSPHRASE [USER] snmpusm [COMMON OPTIONS] [-Ca] [-Cx] changekey [USER] DESCRIPTION
snmpusm is an SNMP application that can be used to do simple maintenance on the users known to an SNMP agent, by manipulating the agent's User-based Security Module (USM) table. The user needs write access to the usmUserTable MIB table. This tool can be used to create, delete, clone, and change the passphrase of users configured on a running SNMP agent. OPTIONS
Common options for all snmpusm commands: -CE ENGINE-ID Set usmUserEngineID to be used as part of the index of the usmUserTable. Default is to use the contextEngineID (set via -E or probed) as the usmUserEngineID. -Cp STRING Set the usmUserPublic value of the (new) user to the specified STRING. Options for the passwd and changekey commands: -Ca Change the authentication key. -Cx Change the privacy key. -Ck Allows to use localized key (must start with 0x) instead of passphrase. When this option is used, either the -Ca or -Cx option (but not both) must also be used. CREATING USERS
An unauthenticated SNMPv3 user can be created using the command snmpusm [OPTIONS] create USER This constructs an (inactive) entry in the usmUserTable, with no authentication or privacy settings. In principle, this user should be useable for 'noAuthNoPriv' requests, but in practise the Net-SNMP agent will not allow such an entry to be made active. In order to activate this entry, it is necessary to "clone" an existing user, using the command snmpusm [OPTIONS] cloneFrom USER CLONEFROM-USER The USER entry then inherits the same authentication and privacy settings (including pass phrases) as the CLONEFROM user. These two steps can be combined into one, by using the command snmpusm [OPTIONS] create USER CLONEFROM-USER The two forms of the create sub-command require that the user being created does not already exist. The cloneFrom sub-command requires that the user being cloned to does already exist. Cloning is the only way to specify which authentication and privacy protocols to use for a given user, and it is only possible to do this once. Subsequent attempts to reclone onto the same user will appear to succeed, but will be silently ignored. This (somewhat unexpected) behaviour is mandated by the SNMPv3 USM specifications (RFC 3414). To change the authentication and privacy settings for a given user, it is necessary to delete and recreate the user entry. This is not necessary for simply changing the pass phrases (see below). This means that the agent must be initialized with at least one user for each combination of authentication and privacy protocols. See the snmpd.conf(5) manual page for details of the createUser configuration directive. DELETING USERS
A user can be deleted from the usmUserTable using the command snmpusm [OPTIONS] delete USER CHANGING PASS PHRASES
User profiles contain private keys that are never transmitted over the wire in clear text (regardless of whether the administration requests are encrypted or not). To change the secret key for a user, it is necessary to specify the user's old passphrase as well as the new one. This uses the command snmpusm [OPTIONS] [-Ca] [-Cx] passwd OLD-PASSPHRASE NEW-PASSPHRASE [USER] After cloning a new user entry from the appropriate template, you should immediately change the new user's passphrase. If USER is not specified, this command will change the passphrase of the (SNMPv3) user issuing the command. If the -Ca or -Cx options are specified, then only the authentication or privacy keys are changed. If these options are not specified, then both the authentication and privacy keys are changed. snmpusm [OPTIONS] [-Ca] [-Cx] changekey [USER] This command changes the key in a perfect-forward-secrecy compliant way through a diffie-helman exchange. The remote agent must support the SNMP-USM-DH-OBJECTS-MIB for this command to work. The resulting keys are printed to the console and may be then set in future command invocations using the --defAuthLocalizedKey and --defPrivLocalizedKey options or in your snmp.conf file using the defAuthLocalizedKey and defPrivLocalizedKey keywords. Note that since these keys are randomly generated based on a diffie helman exchange, they are no longer derived from a more easily typed password. They are, however, much more secure. To change from a localized key back to a password, the following variant of the passwd sub-command is used: snmpusm [OPTIONS] <-Ca | -Cx> -Ck passwd OLD-KEY-OR-PASSPHRASE NEW-KEY-OR-PASSPHRASE [USER] Either the -Ca or the -Cx option must be specified. The OLD-KEY-OR-PASSPHRASE and/or NEW-KEY-OR-PASSPHRASE arguments can either be a passphrase or a localized key starting with "0x", e.g. as printed out by the changekey sub-command. EXAMPLES
Let's assume for our examples that the following VACM and USM configurations lines were in the snmpd.conf file for a Net-SNMP agent. These lines set up a default user called "initial" with the authentication passphrase "setup_passphrase" so that we can perform the initial setup of an agent: # VACM configuration entries rwuser initial # lets add the new user we'll create too: rwuser wes # USM configuration entries createUser initial MD5 setup_passphrase DES Note: the "initial" user's setup should be removed after creating a real user that you grant administrative privileges to (like the user "wes" we'll be creating in this example. Note: passphrases must be 8 characters minimum in length. Create a new user snmpusm -v3 -u initial -n "" -l authNoPriv -a MD5 -A setup_passphrase localhost create wes initial Creates a new user, here named "wes" using the user "initial" to do it. "wes" is cloned from "initial" in the process, so he inher- its that user's passphrase ("setup_passphrase"). Change the user's passphrase snmpusm -v 3 -u wes -n "" -l authNoPriv -a MD5 -A setup_passphrase localhost passwd setup_passphrase new_passphrase After creating the user "wes" with the same passphrase as the "initial" user, we need to change his passphrase for him. The above command changes it from "setup_passphrase", which was inherited from the initial user, to "new_passphrase". Test the new user snmpget -v 3 -u wes -n "" -l authNoPriv -a MD5 -A new_passphrase localhost sysUpTime.0 If the above commands were successful, this command should have properly performed an authenticated SNMPv3 GET request to the agent. Now, go remove the vacm "group" snmpd.conf entry for the "initial" user and you have a valid user 'wes' that you can use for future trans- actions instead of initial. WARNING
Manipulating the usmUserTable using this command can only be done using SNMPv3. This command will not work with the community-based ver- sions, even if they have write access to the table. SEE ALSO
snmpd.conf(5), snmp.conf(5), RFC 3414 4th Berkeley Distribution 22 Oct 2005 SNMPUSM(1)
All times are GMT -4. The time now is 06:58 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy