Sponsored Content
Full Discussion: Replace text in columns
Top Forums Shell Programming and Scripting Replace text in columns Post 302977936 by ctrld on Sunday 24th of July 2016 12:23:35 AM
Old 07-24-2016
Replace text in columns

I have two files in below formats:

Code:
cat file1
abc|abcd|10|1020
10|xyz|1010|1020
abc|abcd|10|1020
10|xyz|1010|1020

cat file2
abc|abcd|10|1020
11|xyz|1010|1020
abc|abcd|12|1020
10|xyz|1011|1020
abc|abcd|11|1020
10|xyz|1010|1020
abc|abcd|10|1020
10|xyz|1010|1020

I am generating a html file using the second table. I need to change the font colour of those lines in second file which are in file1. Although i can match lines and replace with sed, i need to have a html tag wrapped with every column (delimiter is "|") . My expected output is ,
Code:
cat file2
<p><span style="color: #ff0000;">abc</span></p>|<p><span style="color: #ff0000;">abcd</span></p>|<p><span style="color: #ff0000;">10</span></p>|<p><span style="color: #ff0000;">1020</span></p>
11|xyz|1010|1020
abc|abcd|12|1020
10|xyz|1011|1020
abc|abcd|11|1020
<p><span style="color: #ff0000;">10</span></p>|<p><span style="color: #ff0000;">xyz</span></p>|<p><span style="color: #ff0000;">1010</span></p>|<p><span style="color: #ff0000;">1020</span></p>
<p><span style="color: #ff0000;">abc</span></p>|<p><span style="color: #ff0000;">abcd</span></p>|<p><span style="color: #ff0000;">10</span></p>|<p><span style="color: #ff0000;">1020</span></p>
<p><span style="color: #ff0000;">10</span></p>|<p><span style="color: #ff0000;">xyz</span></p>|<p><span style="color: #ff0000;">1010</span></p>|<p><span style="color: #ff0000;">1020</span></p>

I tried to replace by using IFS value as "|" but then it replaced everywhere in file.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

search and replace a specific text in text file?

I have a text file with following content (3 lines) filename : output.txt first line:12/12/2008 second line:12/12/2008 third line:Y I would like to know how we can replace 'Y' with 'N' in the 3rd line keeping 1st and 2nd lines same as what it was before. I tried using cat output.txt... (4 Replies)
Discussion started by: santosham
4 Replies

2. UNIX for Dummies Questions & Answers

Replace columns from File1 with columns from File2

Hi all, I would like to replace some columns from file1 with columns from file2. Currently, I'm able to do it with the following command: awk 'NR==FNR{a=$1;b=$2;c=$3;next;} {$2=a;$4=b;$5=c;print}' file2 file1 > temp mv -f temp file1 First, i make the changes and save it as a temp... (1 Reply)
Discussion started by: seijihiko
1 Replies

3. UNIX for Dummies Questions & Answers

How to convert text to columns in tab delimited text file

Hello Gurus, I have a text file containing nearly 12,000 tab delimited characters with 4000 rows. If the file size is small, excel can convert the text into coloumns. However, the file that I have is very big. Can some body help me in solving this problem? The input file example, ... (6 Replies)
Discussion started by: Unilearn
6 Replies

4. Shell Programming and Scripting

Replace specific columns in one file with columns in another file

HELLO! This is my first post here! By the way, I think it is great that people do this. My question: I have two files, one is a .dilm and one is a .txt. It is my understanding that the .dilm file can be treated as a .txt file. I wrote another program where I was able to manipulate it as if it... (3 Replies)
Discussion started by: mehdib
3 Replies

5. Shell Programming and Scripting

Find and add/replace text in text files

Hi. I would like to have experts help on below action. I have text files in which page nubmers exists in form like PAGE : 1 PAGE : 2 PAGE : 3 and so on there is other text too. I would like to know is it possible to check the last occurance of Page... (6 Replies)
Discussion started by: lodhi1978
6 Replies

6. Shell Programming and Scripting

Replace columns of one file into another

Hi, I have two files that are different in size (column #'s differ). Each file has the exact same 3 starting columns. File 1 has 240 columns while File 2 has 45 columns. So if the first 3 columns are the same, I want to replace columns 83 to 163 from File 1 with columns 18 to 33 from File... (7 Replies)
Discussion started by: kylle345
7 Replies

7. UNIX for Dummies Questions & Answers

Removing columns from a text file that do not have any values in second and third columns

I have a text file that has three columns. But at the end of the text file, there are trailing lines that have missing second and third columns: 4 0.04972604 KLHL28 4 0.0497332 CSTB 4 0.04979822 AIF1 4 0.04983331 DECR2 4 0.04990344 KATNB1 4 4 4 4 How can I remove the trailing... (3 Replies)
Discussion started by: evelibertine
3 Replies

8. Shell Programming and Scripting

Replace text in column1 of a file matching columns of another file

Hi all, I have 2 files: species-names.txt Abaca-bunchy-top-virus ((((Abaca-bunchy-top-virus((Babuvirus((Unassigned((Nanoviridae((Unassigned)))) Abutilon-mosaic-virus ((((Abutilon-mosaic-virus((Begomovirus((Unassigned((Geminiviridae((Unassigned))))... (2 Replies)
Discussion started by: thienxho
2 Replies

9. Shell Programming and Scripting

Match on columns and replace other columns

Hi Friends, I have the following input file cat input chr1 100 200 0.1 0.2 na 1 na nd chr1 105 200 0.1 0.2 1 1 na 98 chr1 110 290 nf 1 na nd na 1 chr2 130 150 12 3 na 1 na 1 chr3 450 600 nf nf na 10 na nd chr4 300 330 1 1 10 11 23 34 My requirement is 1. If $6 is na make $7 nd and... (2 Replies)
Discussion started by: jacobs.smith
2 Replies

10. Shell Programming and Scripting

How to concatenate 2-columns by 2 -columns for a text file?

Hello, I want to concatenate 2-columns by 2-columns separated by colon. How can I do so? For example, I have a text file containing 6 columns separated by tab. I want to concatenate column 1 and 2; column 3 and 4; column 5 and 6, respectively, and put a colon in between. input file: 1 0 0 1... (10 Replies)
Discussion started by: huiyee1
10 Replies
KAS_LISTTICKETS(8)					       AFS Command Reference						KAS_LISTTICKETS(8)

NAME
kas_listtickets - Displays all of the issuer's tickets (tokens) SYNOPSIS
kas listtickets [-name <name of server>] [-long] [-help] kas listt [-n <name of server>] [-l] [-h] DESCRIPTION
The kas listtickets command displays the associated user ID (AFS UID), cell name, and expiration date of some or all of the issuer's tickets (tokens), depending on which options are provided: o To display all tokens, provide neither the -name argument nor -long flag. The output is similar to that of the tokens command. o To display a single token, provide the -name argument to specify name of the Authentication Database entry for the entity that accepts the token. All AFS server processes accept tokens sealed with the key from the "afs" entry. o To display in addition the octal numbers that constitute the token and session key, provide the -long flag. OPTIONS
-name <name of server> Names the Authentication Database entry of the entity (usually a server process) that accepts the token to display. -long Displays the octal numbers that constitute the session key and ticket. -help Prints the online help for this command. All other valid options are ignored. OUTPUT
The output reports the AFS UID of the user who owns the token, the service (usually, "afs") and cell for which it is valid, and its expiration date, using the following format. If the message does not specify a cell, the ticket is for the local cell. User's (AFS ID <AFS UID>) tokens for <service>[@<cellname>] [Expires <date>] If the -long flag is provided, the output also includes the octal numbers making up the session key and token, along with the key version number and the number of bytes in the token (if the number of bytes is not 56, there is an error). If the marker "[>> POSTDATED <]" appears instead of an expiration date, the ticket does not become valid until the indicated time. (Only internal calls can create a postdated ticket; there is no standard interface that allows users to do this.) EXAMPLES
The following two examples are for a user with AFS UID 1020 in the "abc.com" cell and AFS UID 35 in the "test.abc.com" cell. He is working on a machine in the first cell and is authenticated in both cells. % kas listtickets User's (AFS ID 1020) tokens for afs [Expires Wed Mar 31 9:30:54 1999] User's (AFS ID 35@test.abc.com) tokens for afs@test.abc.com [Expires Wed Mar 31 13:54:26 1999] % kas listtickets -name afs -long User's (AFS ID 1020) tokens for afs [Expires Wed Mar 31 9:30:54 1999] SessionKey: 3752053512273231026313 Ticket: (kvno = 0, len = 56): 33052211562032783125816133... PRIVILEGE REQUIRED
None, and no password is required. SEE ALSO
kas(8), tokens(1) COPYRIGHT
IBM Corporation 2000. <http://www.ibm.com/> All Rights Reserved. This documentation is covered by the IBM Public License Version 1.0. It was converted from HTML to POD by software written by Chas Williams and Russ Allbery, based on work by Alf Wachsmann and Elizabeth Cassell. OpenAFS 2012-03-26 KAS_LISTTICKETS(8)
All times are GMT -4. The time now is 07:22 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy