Sponsored Content
Top Forums Shell Programming and Scripting How to search and replace string from nth column from a file? Post 302960098 by RudiC on Tuesday 10th of November 2015 03:37:44 PM
Old 11-10-2015
Amit, you can simplify as you did unless there are fields in quotes that have commas in them.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Search and replace string only in a particular column in a delimited file

I have file with multiple columns. Column values for a record may be same. Now i have to replace a column value(this can be same for the other columns) with new value. File.txt A,B,C,D,A,B,C,D,A,B,C,D A,B,C,D,A,B,C,D,A,B,C,D A,B,C,D,A,B,C,D,A,B,C,D A,B,C,D,A,B,C,D,A,B,C,D... (1 Reply)
Discussion started by: ksailesh
1 Replies

2. UNIX for Dummies Questions & Answers

Search a string in the file and then replace another string after that position

Hi I am looking for a particular string in a file.If the string exists, then I want to replace another string with some other text.Once replaced, search for the same text after that character position in the file. :wall: E.g: Actual File content: Hello Name: Nitin Raj Welcome to Unix... (4 Replies)
Discussion started by: dashing201
4 Replies

3. Shell Programming and Scripting

Replace the nth column date as MM/DD/YYYY

Hi, I need some unix command to replace the following thing. cat test.dat 1234|test|8/19/2009|8/20/2009|test 1234|test|8/9/2009|8/21/2009|test 1234|test|8/1/2009|8/2/2009|test after processing 1234|test|08/19/2009|08/20/2009|test 1234|test|08/09/2009|08/21/2009|test... (6 Replies)
Discussion started by: anshaa
6 Replies

4. Shell Programming and Scripting

awk to search for specific line and replace nth column

I need to be able to search for a string in the first column and if that string exists than replace the nth column with "-9.99". AW12000012012 2.38 1.51 3.01 1.66 0.90 0.91 1.22 0.82 0.57 1.67 2.31 3.63 0.00 AW12000012013 1.52 0.90 1.20 1.34 1.21 0.67 ... (14 Replies)
Discussion started by: ncwxpanther
14 Replies

5. Shell Programming and Scripting

How to search and replace string in column in file with command sed?

how to search and replace string in column in file with command sed or other search "INC0000003.in" and replace column 4 = "W" $ cat file.txt INC0000001.in|20150120|Y|N|N INC0000002.in|20150120|Y|N|N INC0000003.in|20150120|Y|N|N INC0000004.in|20150120|Y|N|Noutput... (4 Replies)
Discussion started by: ppmanja3
4 Replies

6. UNIX for Dummies Questions & Answers

Search for a string,delete the line and replace with new string in a file

Hi Everyone, I have a requirement in ksh where i have a set of files in a directory. I need to search each and every file if a particular string is present in the file, delete that line and replace that line with another string expression in the same file. I am very new to unix. Kindly help... (10 Replies)
Discussion started by: Pradhikshan
10 Replies

7. Shell Programming and Scripting

awk search and replace nth column by using a variable.

I am passing a variable and replace nth value with the variable. I tried using many options in awk command but unable to ignore the special characters in the output and also unable to pass the actual value. Input : "1","2","3" Output : "1","1000","3" TempVal=`echo 1000` Cat... (2 Replies)
Discussion started by: onesuri
2 Replies

8. Shell Programming and Scripting

Search term in nth field and replace kth column

Hi, I have a text file which looks like this a.txt A,12,Apple,Red B,33,Banana,Yellow C,66,Sky,Blue I need to search for a particular field(s) in particular column(s) and for that matching line need to replace the nth column. Sample scenario 1: Search for 66 in second field and Sky in... (5 Replies)
Discussion started by: wahi80
5 Replies

9. Shell Programming and Scripting

Replace Value of nth Column of Each Line Using Array

Hello All, I am writing a shell script with following requirement: 1. I have one input file as below CHE01,A,MSC,INO CHE02,B,NST,INC CHE03,C,STM,INP 2. In shell script I have predefined array as below: Array1={A, B, C} Array2= {U09, C04, A054} (6 Replies)
Discussion started by: angshuman
6 Replies

10. UNIX for Beginners Questions & Answers

Search partial string in a file and replace the string - UNIX

I have the below string which i need to compare with a file and replace this string in the file which matches closely. Can anyone help me on this. string(Scenario 1)- user::r--,user::ourfrd:r-- String(Scenario 2)- user::r-- File **** # file: /local/Desktop/myfile # owner: me # group:... (6 Replies)
Discussion started by: sarathy_a35
6 Replies
ctstat(1)                                                          User Commands                                                         ctstat(1)

NAME
ctstat - display active system contracts SYNOPSIS
/usr/bin/ctstat [-a] [-i contractid...] [-t type...] [-v] [interval [count]] DESCRIPTION
The ctstat utility allows a user to observe the contracts active on a system. Unless you specify the -i or -t option, ctstat displays statistics on all contracts in the system. OPTIONS
The following options are supported: -a Display all contracts regardless of state. By default, this option only displays those contracts which are in the owned, inherited, or orphan states. -i contractid... Request status on the specified contracts, identified by their numeric contract identifier (contract_id). This option accepts lists as arguments . Items in the list can be separated by commas, or enclosed in quotes and separated by commas or spaces. -t type... Request status on contracts of the specified type (type). This option accepts lists as arguments. Items in the list can be separated by commas, or enclosed in quotes and separated by commas or spaces. The following types are supported: process Process contracts -v Verbose output. OPERANDS
The following operands are supported: interval Report once each interval seconds. count Print only count reports. OUTPUT
The following list defines the column headings and the meanings of a ctstat report: CTID The contract ID of the contract. ZONEID The zone ID of the contract's creator. TYPE The contract type. STATE The state of the contract: owned Contract is owned by a process. inherited The contract owner has exited abnormally and the contract has been inherited by the owner's process contract. orphan The contract owner has abandoned the contract, the contract owner exited abnormally and the contract was not inherited by the owner's process contract, or the process contract which had inherited the con- tract was abandoned by its owner. dead The contract is no longer active. It is removed from the system automatically when all references to it (open file descriptors, contract templates, and events) have been released. HOLDER If the contract is in the owned state, the pid of the process that owns the contract. If the contract is in the inherited state, the id of the regent process contract. EVENTS The number of unacknowledged critical events pending. QTIME The time until quantum ends, or - if no negotiation is in progress. NTIME The time until negotiation ends, or - if no negotiation is in progress. EXAMPLES
Example 1: Reporting on all Contracts in the System The following example reports on all contracts in the system: example% ctstat -a CTID TYPE STATE HOLDER EVENTS QTIME NTIME 1 process owned 100579 0 - - 2 process dead - 1 - - 3 process inherit 1 3 - - 4 process orphan - 0 - - Example 2: Obtaining a Verbose Report of All Contracts in the System The following example obtains a verbose report of all contracts in the system: example% ctstat -av CTID TYPE STATE HOLDER EVENTS QTIME NTIME 1 process owned 100579 0 - - informative event set: none critical event set: hwerr core fatal event set: hwerr parameter set: none member processes: 100600 100601 inherited ctids: none 2 process dead - 1 - - informative event set: none critical event set: none fatal event set: hwerr core parameter set: pgrponly member processes: none inherited ctids: none EXIT STATUS
The following exit values are returned: 0 Successful completion. 1 An error occurred. 2 Invalid arguments. FILES
/system/contract/* ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWcsu | +-----------------------------+-----------------------------+ |Interface Stability |See below. | +-----------------------------+-----------------------------+ Human Readable Output is Unstable. Invocation is Evolving. SEE ALSO
ctrun(1), ctwatch(1), contract(4), process(4), attributes(5) SunOS 5.10 15 Jul 2004 ctstat(1)
All times are GMT -4. The time now is 07:48 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy