Sponsored Content
Top Forums Shell Programming and Scripting Combine first two words ( country name ) into one word in every line of log file with 500 records Post 303037117 by bakunin on Wednesday 24th of July 2019 05:26:32 AM
Old 07-24-2019
Depending on how (and by what) you further process your data you can also do it in shell directly instead of calling awk for only that purpose:

Quote:
Originally Posted by arm
Code:
United States 1.2.3.4  80  10 1563790914  1   1932454179 1.2.3.6  55517  11.1.2.1  55517
Italy  1.2.3.4  80  10 1563790914  1   1932454179 1.2.3.6  55517  11.1.2.1  55517
India  1.2.3.4  80  10 1563790914  1   1932454179 1.2.3.6  55517  11.1.2.1  55517
south Africa  1.2.3.4  80  10 1563790914  1   1932454179 1.2.3.6  55517  11.1.2.1  55517

output will be :
Code:
UnitedStates 1.2.3.4  80  10 1563790914  1   1932454179 1.2.3.6  55517  11.1.2.1  55517
Italy  1.2.3.4  80  10 1563790914  1   1932454179 1.2.3.6  55517  11.1.2.1  55517
ndia  1.2.3.4  80  10 1563790914  1   1932454179 1.2.3.6  55517  11.1.2.1  55517
southAfrica  1.2.3.4  80  10 1563790914  1   1932454179 1.2.3.6  55517  11.1.2.1  55517 

Code:
while read f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 ; do
     if [ -n "$f12" ] ; then
          printf "%s %s %s %s %s %s %s %s %s %s %s\n" "${f1}${f2}" "$f3" "$f4" "$f5" "$f6" "$f7" "$f8" "$f9" "$f10" "$f11" "$f12"
     else
          printf "%s %s %s %s %s %s %s %s %s %s %s\n" "${f1}" "${f2}" "$f3" "$f4" "$f5" "$f6" "$f7" "$f8" "$f9" "$f10" "$f11"
     fi
done < /path/to/input

Adjust the printf-format string to fine-tune the output format.

I hope this helps.

bakunin
This User Gave Thanks to bakunin For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to replace a word with a series of words in a file

Hi, I have a Template file 'TL.body' which says as follows: "There are no <FILENAME> files on the server. " The missing file names are identified and stored in a variable. For Eg: MISSFILE="abc.txt def.txt xyz.txt" I want the values of MISSFILE variable to be replaced against... (2 Replies)
Discussion started by: brap45
2 Replies

2. Shell Programming and Scripting

How to remove all words starting from a matching word in a line

Hi Guys, I have a file like this: wwwe 1 ioie ewew yyy uuu 88 erehrlk 4 ihoiwhe lkjhassad lkhsad yyy mmm 45 jhash lhasdhs lkhsdkjsn ouiyrshroi oihoihswodnw oiyhewe yyy ggg 77 I want to remove everything after "yyy" and including "yyy" from each line in the file. So I want:... (2 Replies)
Discussion started by: npatwardhan
2 Replies

3. Shell Programming and Scripting

How to remove all words from a matching word in a line?

Hi Guys, :p I have a file like this: 2010-04-25 00:00:30,095 INFO - ]- start process U100M4 2010-04-25 00:00:30,096 DEBUG - ] -- call EJB 2010-04-25 00:00:30,709 INFO - - end processU100M4 2010-04-25 00:00:30,710 DEBUG - got message=Sorry I want to out put format. 2010-04-25... (5 Replies)
Discussion started by: ooilinlove
5 Replies

4. UNIX for Dummies Questions & Answers

Grep specific records from a file of records that are separated by an empty line

Hi everyone. I am a newbie to Linux stuff. I have this kind of problem which couldn't solve alone. I have a text file with records separated by empty lines like this: ID: 20 Name: X Age: 19 ID: 21 Name: Z ID: 22 Email: xxx@yahoo.com Name: Y Age: 19 I want to grep records that... (4 Replies)
Discussion started by: Atrisa
4 Replies

5. UNIX for Advanced & Expert Users

cut words based on the word count of a line

I would like to cut words based on the word count of a line. This over here inspired me with some ideas but I wasn't able to get what I needed. https://www.unix.com/shell-programming-scripting/105841-count-words-each-line-file-using-xargs.html If the line has 6 words I would like to use this.... (8 Replies)
Discussion started by: cokedude
8 Replies

6. Shell Programming and Scripting

Combine multiple unique lines from event log text file into one line, use PERL or AWK?

I can't decide if I should use AWK or PERL after pouring over these forums for hours today I decided I'd post something and see if I couldn't get some advice. I've got a text file full of hundreds of events in this format: Record Number : 1 Records in Seq : ... (3 Replies)
Discussion started by: Mayday22
3 Replies

7. Shell Programming and Scripting

Compare multiple files, identify common records and combine unique values into one file

Good morning all, I have a problem that is one step beyond a standard awk compare. I would like to compare three files which have several thousand records against a fourth file. All of them have a value in each row that is identical, and one value in each of those rows which may be duplicated... (1 Reply)
Discussion started by: nashton
1 Replies

8. Shell Programming and Scripting

Read a File line by line and split into array word by word

Hi All, Hope you guys had a wonderful weekend I have a scenario where in which I have to read a file line by line and check for few words before redirecting to a file I have searched the forum but,either those answers dint work (perhaps because of my wrong under standing of how IFS... (6 Replies)
Discussion started by: Kingcobra
6 Replies

9. UNIX for Advanced & Expert Users

Sort words based on word count on each line

Hi Folks :) I have a .txt file with thousands of words. I'm trying to sort the lines in order based on number of words per line. Example from: word word word word word word word word word word word word word word word word to desired output: word (2 Replies)
Discussion started by: martinsmith
2 Replies

10. Shell Programming and Scripting

Replace particular words in file based on if finds another words in that line

Hi All, I need one help to replace particular words in file based on if finds another words in that file . i.e. my self is peter@king. i am staying at north sydney. we all are peter@king. How to replace peter to sham if it finds @king in any line of that file. Please help me... (8 Replies)
Discussion started by: Rajib Podder
8 Replies
TN5250(1)						      General Commands Manual							 TN5250(1)

NAME
tn5250 - an implementation of the 5250 telnet protocol SYNOPSIS
tn5250 [OPTIONS] HOSTNAME xt5250 [OPTIONS] HOSTNAME tn5250 -version DESCRIPTION
tn5250 emulates IBM's 5250 compatible terminals to connect over TCP/IP to an IBM AS/400. The terminal emulation works on any local termi- nal supported by curses, and provides 132x27 and full colour support where possible. An IBM 5250 terminal supports a number of special keys, and does a lot of processing itself before sending data to the host system. Because a standard ASCII terminal does not support all these keys, tn5250 uses control sequences to perform the operations. Named session support (with the env.DEVNAME option) is available for most versions of OS/400, but is only supplied with V4R3 and later ver- sions. For V3R2, V3R7, V4R1 and V4R2, please see informational APAR II10918. OPTIONS
tn5250 options are described in the tn5250rc(5) man page. USAGE
This manual assumes that the user is familiar with a real 5250 terminal, or another 5250 emulator, and only describes features relevant to tn5250 itself. Keyboard Mapping The following table lists the 5250 functions implemented by tn5250, and the corresponding keypresses. Keys are represented as Emacs does: C-a means hold Ctrl and press A, M-a means press Esc or C-g followed by A, and C-M-a means press Esc or C-g followed by C-a. Most setups also let you use the Alt or Meta key for M- keypresses. Function Keypress ---------------------------------------- F1 - F10 f1 to f10, M-1 to M- F11 f11 [1], M-- F12 f12 [1], M-= F13 - F24 f13 to f24 [1], M-! to M-+ Enter return, enter, C-j, C-m Left left Right right Up up Down down Roll Up next, pagedown, C-d, C-f Roll Down prev, pageup, C-b, C-u Backspace backspace [1] Home home, C-o End end Insert insert, M-i, M-delete Delete delete [1] Reset C-r, M-r Print C-p, M-p Help M-h SysReq C-c, M-s Clear M-c FieldExit C-k, M-x TestReq C-t Toggle M-t Erase C-e Attn C-a, M-a Dup M-d Field+ C-x, + [2] Field- M-m, - [2] NewLine C-M-j Next Field tab, C-i Prev Field backtab [1] ---------------------------------------- Refresh C-l, M-l Quit C-q 1. Which keys generate f11-f24, backtab, backspace and delete is very dependent on the configuration of the terminal. 2. + and - only work as Field+ and Field- in signed numeric fields. Display The screen display tries to be the same as a colour 5250 terminal. There are some unavoidable differences though: o ASCII terminals (and curses) do not support the 5250 column separators. o Some terminals (mostly ones based on the VGA text mode) do not support underlining. If this is the case and tn5250 does not detect it automatically, you should pass the -u option. o Some terminals (such as xterm) do not support blinking text. EXAMPLES
These are some examples of the use of tn5250: tn5250 as400sys Connect to the system as400sys, using the default translation map (37) and a generated session name (QPADEV####). tn5250 map=870 env.DEVNAME=session1 env.TERM=IBM-3477-FC as400sys Connect to as400sys using the translation map for CCSID 870 (Eastern Europe), the session name SESSION1 and with a terminal support- ing colour and a 132x27 display. BUGS
Please report any bugs you find to the bug tracker or to the linux5250 mailing list. See the tn5250 web site for more details. SEE ALSO
tn5250rc(5), lp5250d(1), http://tn5250.sourceforge.net/, RFC1205, RFC2877, II10918. COPYRIGHT
tn5250 is copyright 1997 - 2008 Michael Madore. This manpage is copyright 1999 - 2008 Carey Evans. This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as pub- lished by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MER- CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foun- dation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA AUTHORS
tn5250 was written by Michael Madore, Jay Felice, Scott Klement and others; see the AUTHORS file for details. This manual page was written by Carey Evans. 12 November 2001 TN5250(1)
All times are GMT -4. The time now is 01:14 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy