Sponsored Content
Top Forums Shell Programming and Scripting Reverse specific field number Post 302959299 by netsys on Saturday 31st of October 2015 07:54:59 AM
Old 10-31-2015
Code:
usage: uniq [-c | -du | -i] [-f fields] [-s chars] [input [output]]

I am using FreeBSD 3.2-RELEASE so optin -w doesn't work.

INPUT -

Code:
koren14          ttyp9    tomo100.ynet.sk  Thu Oct  1 10:34 - 11:37  (01:03)
kanuch14         ttyp8    pe3k.ynet.sk     Thu Oct  1 10:27 - 10:39  (00:11)
baranek13        ttyp7    188-167-149-232. Thu Oct  1 09:54 - 14:05  (04:11)
lastinec         ttyp3    147.175.145.131  Thu Oct  1 09:52 - 12:09  (02:16)
baranek13        ttyp7    188-167-149-232. Thu Oct  1 09:32 - 09:54  (00:21)
labaj13          ttyp7    147.175.123.164  Thu Oct  1 09:22 - 09:24  (00:02)
knapik13         ttyp9    cpu-c04.ucebne.f Thu Oct  1 09:12 - 09:41  (00:29)
jelencik13       ttyp8    cpu-c05.ucebne.f Thu Oct  1 09:12 - 09:19  (00:07)
pavkovce14       ttyp7    pavkovcek.ynet.s Thu Oct  1 09:10 - 09:13  (00:03)
nemec14          ttyp3    151.236.226.58   Thu Oct  1 09:05 - 09:32  (00:27)
vozar14          ttyp3    fvozar.eu        Thu Oct  1 09:01 - 09:01  (00:00)
slovikm13        ttyp3    217.119.114.218  Thu Oct  1 08:49 - 08:50  (00:00)
nemec14          ttyp7    151.236.226.58   Thu Oct  1 08:33 - 08:40  (00:06)
lam13            ttyp4    fei-free-27.wifi Thu Oct  1 08:33 - 10:53  (02:19)
lastinec         ttyp3    chello0891730632 Thu Oct  1 08:23 - 08:47  (00:23)

wtmp begins Thu Oct  1 08:23:46 2015


Last edited by Don Cragun; 10-31-2015 at 04:07 PM.. Reason: Add CODE tags.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

cut a field, but with reverse order

Hi Everyone, I have one a.txt: a b 001 c b b 002 c c c, not 002 c The output should be 001 002 002 If i use cut -f 3 -d' ', this does not work on the 3rd line, so i thought is any way to cut the field counting from the end? or any perl thing can do this?:confused: ... (3 Replies)
Discussion started by: jimmy_y
3 Replies

2. Shell Programming and Scripting

Sorting on two fields time field and number field

Hi, I have a file that has data in it that says 00:01:48.233 1212 00:01:56.233 345 00:09:01.221 5678 00:12:23.321 93444 The file has more line than this but i just wanted to put in a snippet to ask how I would get the highest number with time stamp into another file. So from the above... (2 Replies)
Discussion started by: pat4519
2 Replies

3. Shell Programming and Scripting

Adding total of first field for each number in the second field

Dears, I need a script or command which can find the unique number from the second filed and against that number it adds the total of first field . 17215630 , 0 907043 ,1 201050 ,10 394149 ,4 1964 ,9 17215630, 0 907043 ,1 201050, 10 394149 ,4 1964 ,9 1234234, 55 23 ,100 33 ,67 ... (2 Replies)
Discussion started by: shary
2 Replies

4. 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

5. Shell Programming and Scripting

awk assign output of array to specific field-number

With this script i want to print the output to a specific field-number . Can anybody help? awk 'NR=FNR{split(FILENAME,fn,"_");nr=$2;f = $1} END{for (i=1;i<=f;i++) print i,$fn=nr}' input_5.csv input_6.csvinput_5.csv 4 135 5 185 6 85 11 30input_6.csv 1 90 3 58 4 135 7 60 8 55 10... (1 Reply)
Discussion started by: sdf
1 Replies

6. Shell Programming and Scripting

Using a reverse regex to create a number

Hi all, I'm having an issue about a code i should write... I have a file... with the following numbers in regex format: $ cat file_regex.txt 55500508007* 55500218200* 182936* 182929* 4179* 381* 550069341* So this is a file cointaing some regex... so for each regex i need to... (3 Replies)
Discussion started by: poliver
3 Replies

7. UNIX for Dummies Questions & Answers

reverse first field from the file

Hi all, I have a file named file1as 07/25 00:10 d327490 07/25 00:55 d378299 07/25 03:58 d378299 07/25 06:14 d642035 07/25 12:44 c997126 and now i want to reverse the first filed ie 07/25 as 25/07 00:10 d327490 25/07 00:55 d378299 25/07 03:58 d378299 25/07 06:14 d642035 25/07... (5 Replies)
Discussion started by: zozoo
5 Replies

8. Shell Programming and Scripting

How to reverse all columns of a file having some field separator?

Hello, I have a file: xandyandz x & y & z x*y*z*a I require output as: zandyandx z & y & x a*z*y*x here all lines have different field seperator (and & * )based on that i want to reverse the column of a file. Pl. help. (8 Replies)
Discussion started by: nehashine
8 Replies

9. 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

10. Shell Programming and Scripting

awk to find number in a field then print the line and the number

Hi I want to use awk to match where field 3 contains a number within string - then print the line and just the number as a new field. The source file is pipe delimited and looks something like 1|net|ABC Letr1|1530||| 1|net|EXP_1040 ABC|1121||| 1|net|EXP_TG1224|1122||| 1|net|R_North|1123|||... (5 Replies)
Discussion started by: Mudshark
5 Replies
All times are GMT -4. The time now is 11:52 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy