Sponsored Content
Top Forums Shell Programming and Scripting How to append a character to the last but one field on a specific line? Post 302391880 by npatwardhan on Tuesday 2nd of February 2010 07:40:04 PM
Old 02-02-2010
How to append a character to the last but one field on a specific line?

Hi Guys,

I have a file like this:

Code:
aaa  b c d e f 
fsss  g h i  k l
qqq   r t h n

I want:

Code:
aaa  b c d e  f 
fsss  g h i  k  l
qqq   r t h  ,  n 
ggg   p t e d u 
qqq   i o s ,  k

So I want to insert a comma at the last but one location of every line that matches "qqq".

I tried to use the gsub command but could not get the second from last character to be inserted in awk.

Thanks in advance.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Using SED to append character to each line

Hey - my first post here, and I'm a total SED newb. I've looked around for previous help on this, but have so far been unsuccessful. I have a program (AMStracker for OS X) that outputs data in the terminal. Output is in this form: . . . 3 0 -75 3 0 -76 3 0 -77 ... (4 Replies)
Discussion started by: c0nn0r
4 Replies

2. Shell Programming and Scripting

append a character at end of each line of a file

Hi, i want to append a character '|' at end of each line of a file abc.txt. for example if the file abc.txt conatins: a|b|c 1|2|33 w|2|11 i want result file xyz.txt a|b|c| 1|2|33| w|2|11| I know this is simple but sumhow i am not able to reach end of line. its urgent, thanks for... (4 Replies)
Discussion started by: muaz
4 Replies

3. Shell Programming and Scripting

awk append to one line if first field is the same

Hi all, How would I append the second field each time to one line if the first field is the same for example I have this data: 10430,187976 10430,251588 10430,262904 10430,275008 10430,279892 10430,275008 10430,303740 10430,318136 10430,336988 10430,350324 10430,373648 And I... (4 Replies)
Discussion started by: borderblaster
4 Replies

4. HP-UX

How to remove new line character and append new line character in a file?

Hi Experts, I have data coming in 4 columns and there are new line characters \n in between the data. I need to remove the new line characters in the middle of the row and keep the \n character at the end of the line. File is comma (,) seperated. Eg: ID,Client ,SNo,Rank 37,Airtel \n... (8 Replies)
Discussion started by: sasikari
8 Replies

5. Shell Programming and Scripting

Using awk to read a specific line and a specific field on that line.

Say the input was as follows: Brat 20 x 1000 32rf Pour 15 p 1621 05pr Dart 10 z 1111 22xx My program prompts for an input, what I want is to use the input to locate a specific field. Like if I type in, "Pou" then it would return "Pour" and just "Pour" I currently have this line but it is... (6 Replies)
Discussion started by: Bungkai
6 Replies

6. Shell Programming and Scripting

Replace specific field on specific line sed or awk

I'm trying to update a text file via sed/awk, after a lot of searching I still can't find a code snippet that I can get to work. Brief overview: I have user input a line to a variable, I then find a specific value in this line 10th field in this case. After asking for new input and doing some... (14 Replies)
Discussion started by: crownedzero
14 Replies

7. Shell Programming and Scripting

How to print with awk specific field different from specific character?

Hello, i need help with awk. I have this file: cat number DirB port 67 er_enc_out 0 er_bad_os 0 DirB port 71 er_enc_out 56 er_bad_os 0 DirB port 74 er_enc_out 0 er_bad_os 0 DirB port 75 ... (4 Replies)
Discussion started by: elilmal
4 Replies

8. Shell Programming and Scripting

File Parsing based on a character in a specific field

Hi All, I'm having a hard time finding a starting point for my issue. I have a 30k line file (fspsec.txt) that I would like to parse into smaller files based on any character existing in field 1. ACCOUNTANT LEVEL 1 (ACCT.ACCOUNTANT) OPERATORS: DOEJO (418) TOOLS: Branch Maintenance ... (2 Replies)
Discussion started by: aahlrich
2 Replies

9. UNIX for Beginners Questions & Answers

Append each line based upon the character size

I have a huge file which contains multiple lines. It need to check whether character length is not more than 255 each line. If its not then it should remove the character up to column. I have described in the output below. If its more than that the next line should start with call but if the... (1 Reply)
Discussion started by: JoshvaPeter
1 Replies

10. Shell Programming and Scripting

Count specific character of a file in each line and delete this character in a specific position

I will appreciate if you help me here in this script in Solaris Enviroment. Scenario: i have 2 files : 1) /tmp/TRANSACTIONS_DAILY_20180730.txt: 201807300000000004 201807300000000005 201807300000000006 201807300000000007 201807300000000008 2)... (10 Replies)
Discussion started by: teokon90
10 Replies
NG_TCPMSS(4)						   BSD Kernel Interfaces Manual 					      NG_TCPMSS(4)

NAME
ng_tcpmss -- netgraph node to adjust TCP MSS option SYNOPSIS
#include <netgraph.h> #include <netgraph/ng_tcpmss.h> DESCRIPTION
The tcpmss node type is designed to alter the Maximum Segment Size option of TCP packets. This node accepts an arbitrary number of hooks. Initially a new hook is considered unconfigured. The NG_TCPMSS_CONFIG control message is used to configure a hook. CONTROL MESSAGES
This node type supports the generic control messages, plus the following. NGM_TCPMSS_CONFIG (config) This control message configures node to do given MSS adjusting on a particular hook. It requires the struct ng_tcpmss_config to be sup- plied as an argument: struct ng_tcpmss_config { char inHook[NG_HOOKSIZ]; char outHook[NG_HOOKSIZ]; uint16_t maxMSS; } This means: packets received on inHook would be checked for TCP MSS option and the latter would be reduced down to maxMSS if it exceeds maxMSS. After that, packets would be sent to hook outHook. NGM_TCPMSS_GET_STATS (getstats) This control message obtains statistics for a given hook. The statistics are returned in struct ng_tcpmss_hookstat: struct ng_tcpmss_hookstat { uint64_t Octets; /* total bytes */ uint64_t Packets; /* total packets */ uint16_t maxMSS; /* maximum MSS */ uint64_t SYNPkts; /* TCP SYN packets */ uint64_t FixedPkts; /* changed packets */ }; NGM_TCPMSS_CLR_STATS (clrstats) This control message clears statistics for a given hook. NGM_TCPMSS_GETCLR_STATS (getclrstats) This control message obtains and clears statistics for a given hook. EXAMPLES
In the following example, packets are injected into the tcpmss node using the ng_ipfw(4) node. # Create tcpmss node and connect it to ng_ipfw node ngctl mkpeer ipfw: tcpmss 100 qqq # Adjust MSS to 1452 ngctl msg ipfw:100 config '{ inHook="qqq" outHook="qqq" maxMSS=1452 }' # Divert traffic into tcpmss node ipfw add 300 netgraph 100 tcp from any to any tcpflags syn out via fxp0 # Let packets continue with ipfw after being hacked sysctl net.inet.ip.fw.one_pass=0 SHUTDOWN
This node shuts down upon receipt of an NGM_SHUTDOWN control message, or when all hooks have been disconnected. SEE ALSO
netgraph(4), ng_ipfw(4) HISTORY
The ng_tcpmss node type was implemented in FreeBSD 6.0. AUTHORS
Alexey Popov <lollypop@flexuser.ru> Gleb Smirnoff <glebius@FreeBSD.org> BUGS
When running on SMP, system statistics may be broken. BSD
June 9, 2005 BSD
All times are GMT -4. The time now is 01:34 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy