-1
votes
1answer
20 views

editing column of a text file

abc.txt consists of two column data as 1 A1021 2 A1021 3 A1022 4 A1022 I want another test file, say pqr.txt (replacing A1021 by 1 and A1022 by 2 and so on). I used the following usual perl ...
0
votes
1answer
29 views

Does an awk script or command execute itself to every line it reads?

I got an awk script named my_awk: #!usr/bin/awk -f { if ($1 == "#START") { FS=":";} else if ($1 == "#STOP") { FS = " ";} else { print $3} } And I invoked it through: cat my_file | awk -f ...
0
votes
1answer
19 views

How to add a prefix to every row of a particular column in a csv file via command line on linux

So basically i am trying to achieve the following.    File before editing.  column-1,   column-2,  column-3,  column-4,  column-5 Row-1-c1, ...
1
vote
2answers
56 views

Replacing every 10th pipe with new line in unix

Lets say I have fields: name, number, id I have a data file: name1|number1|id1|name2|number2|id2...etc I want to replace every 3rd pipe with a new line or '\n' so I get: name1|number1|id1 ...
0
votes
1answer
32 views

how to extract last number sequence in an IP Address (using Linux)

I want to extract the last digits of an IP Address based on the result of ifconfig command. ifconfig often includes a whole heap of output so I'm not really sure how to get the digits that I want. ...
0
votes
1answer
84 views

Piping tail -f into awk

Greeting, I am trying to pipe tail -f into awk to monitor a logfile in realtime, but according to examples, there should be not problem but I can't get it to work. here is the command I'm running ...
0
votes
0answers
49 views

stdbuf not working while unbuffer does

I am trying to apply timestamps to stdout of a process. For the proper timestamps to be applied, I attempt to unbuffer stdout of the process. This works with unbuffer but not with stdbuf as I would ...
0
votes
0answers
28 views

awk remove sign “,” in all columns, if it exists between

My data input file: 508,186,,Name,"VIA PAS, 4",vou1@mail.com, 291,345,,Name2,Votros 73,vou2@mail.com, 911,733,,Name3,zap 101,vou4@mail.com, 9000,32,,Michel,hops 12,"x1@mail.com, vou7@mail.com, ...
0
votes
0answers
6 views

Grep values from nethog and netperf [duplicate]

I need to monitor the network activities of a process and the bandwidth of the connection. So I decided to use nethog and netperf combine with grep and awk to write the values to a file. nethog ...
0
votes
2answers
90 views

Grep values from nethog and netperf

I need to monitor the network activities of a process and the bandwidth of the connection. So I decided to use nethog and netperf combine with grep and awk to write the values to a file. nethog ...
1
vote
2answers
68 views

moving directories after grep

I have isseued the next command in order to move some directories to the "build_tools" folder however the result was not the one I expected. ls -l | grep 2014-03 | awk '{if ($8!=build_tools) print ...
0
votes
2answers
61 views

Replace words on given line numbers

I have a file 1.txt INTEGER-d_int () INTEGER-d_int () INTEGER-d_int ( ) INTEGER-d_intClass() INTEGER-d_intClass new() and I want to replace the occurrence of d_int with d_INT on the ...
1
vote
1answer
442 views

Extract the contents of ELF and write to binary file

I have been trying to extract the contents of a firmware and putting it to a binary file, but with no success. I see the right hex contents, but am not sure how to laid them in bits into a file. ...
1
vote
4answers
402 views

How to split CSV files as per number of rows specified?

I've CSV file (around 10,000 rows ; each row having 300 columns) stored on LINUX server. I want to break this CSV file into 500 CSV files of 20 records each. (Each having same CSV header as present in ...
0
votes
1answer
102 views

Find number in string and replace it

I wrote C++ code and now I want to replace the number in a string by using shell scripts. The part that needs to be replaced: if (random<=90) How I can change the 90 from a shell script? I ...
-1
votes
3answers
155 views

convert text file column field with data dd.mm.yy to dd.mm.YYYY

How to format date for file content using linux command line tools? Input: aaa;1.70;ccc;20.01.13;zz;2013; uuu;2.70;lll;17.12.10;zz;2013; fff;3.70;nnn;31.01.98;zz;2013; auu;8.70;nuu;30.02.96;zz;2013; ...
2
votes
2answers
56 views

Use tail directly on website data, or another utility needed?

I am planning to extract a single field of data from the last line of data on a website to populate an RRD database. I'm running Linux. The website is: ...
0
votes
1answer
57 views

Why is this awk statement not working?

awk 'BEGIN { COLM_FMT = "%-8s, %-8s, %-8s, %-8s, %-8s, %-8s, %-8s, %-8s, %-8s, %-8s, %-8s, %-8s, %-8s, %-8s,\n" } { printf COLM_FMT, ${totals[0]}, ${totals[1]}, ${totals[2]}, ...
0
votes
2answers
31 views

Count the number of lines in a piped input?

While running ps -eaf I see a list of running processes. Is it possible to count the number to lines using awk?
0
votes
4answers
119 views

Changing multiple lines in to single line with spaces in linux

I have following data with multiple lines username: joe empid: 1111 status: resigned username: tom emid: 1234 username: kate empid: 2222 status: resigned What I want is to get the data in to ...
1
vote
2answers
137 views

How can I sort and de-dupe a very long list of words?

I have a 400 megabyte file. The file is a list of words, each word on a single line. End of lines are a mix of cr/lf and lf. Some of the words are unicode. I'd prefer answers for Linux or Windows ...
0
votes
2answers
97 views

Trying to get example from Awk and Sed book to work on Ubuntu 13.04

I have been developing Windows Software for years. I am trying to branch out and learn Linux. It will really help with my new job. I have picked up the book, "Awk and Sed" 2nd Edition. I am ...
1
vote
2answers
254 views

Change names in a column in bash

I have a tab-separated file in Linux that looks like this ~$ head list.tab "x" "1" "FUHGF.jnf.m22-1" "2" "HDFHFEY.gfs.d2-1" "3" "KJFGJF.fr.md2-1" "4" "SDFSDIB.gfd.rtl2-1" "5" "FGJFGOB.hgd.k2-5" "6" ...
0
votes
3answers
2k views

remove text from file

I want to remove some text from file1.txt. I put the text in the file tmp and do: grep -f tmp file.txt But it gives me only the difference. The question is how to remove the difference from ...
0
votes
1answer
103 views

How to split file on basis of size without breaking last line of split file

I have a big file and want to split the file on the basis of size. For e.g. Main file: 10 Mb and then I want to split it into 2 mb parts. But the issue is if I use split -b it breaks the last line ...
0
votes
1answer
171 views

Using awk or cut command to get CPU percentage

I am trying to execute a Linux command through a PHP script to get the CPU percentage for each core: … with cut: $output = null; passthru("mpstat -P ALL | grep 0 | tr -s ' ' | cut -d ' ' -f 4", ...
0
votes
1answer
100 views

Counting by number of occurrences in first column

I have an input file like this: ATTACK-RESPONSES id check returned root BACKDOOR ACKcmdC trojan scan BACKDOOR hack-a-tack attempt BACKDOOR WinCrash 1.0 Server Active ICMP Destination Unreachable ...
0
votes
1answer
134 views

Write output to $TMPDIR/$variable : file does not exist (should be created)

I have the following .sh script in which I am trying to do all major writing in $TMPDIR. However, when it gets to line 86, it returns the following error: ...
8
votes
3answers
2k views

sed: how to replace line if found or append to end of file if not found?

With a single input file that only contains comments (starting with #) and VARIABLE=value lines, is it possible to replace a value for a single variable if found and, otherwise, append the pair to the ...
-1
votes
2answers
389 views

Extract IP addresses in each line of file in shell

I have this input file in ubuntu: 146.14.142.96.17747 197.102.40.184.13748: 146.14.142.96.17747 197.102.40.184.13749: 146.14.142.96.17747 197.102.40.184.13750: 146.114.142.96.17747 ...
0
votes
4answers
277 views

Regular expression to find senders IP using grep or other languages

I have input file that contains: 19:04:01.631948 IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 48) 181.173.82.61.1985 > 250.66.33.195.1985: HSRPv0-hello 20: ...
1
vote
3answers
2k views

extract string from file using shell script or awk

i have txt file that contains some website.i'd like to extract websites how can i do this? xhr_object.open("GET",filename,false ); <li><a href="http://www.dakar.com" ...
-1
votes
2answers
118 views

Replace all numbers following a specific string with another number using sed or awk

I have tried several things but got no luck. I have an input file that has a lot of fields like this one weight=0.123456 mixed with other fields. I want to multiply all such weights by a factor, say ...
1
vote
1answer
405 views

awk - max value of a rolling average

I have a bash command which gives me the highest value in the 9th column of a file: cat "log.txt" | grep 1923 | awk '{print $9}' | sort -n | tail -1 log.txt is a log of CPU usage for process 1923 ...
0
votes
1answer
106 views

Can't use awk in terminal

I want to use awk command to do something, I input awk in terminal, but the terminal show me that awk: cannot open /home/user/myexe/external_symbols.awk (No such file or directory) Someone ...
0
votes
2answers
346 views

creating CDF data using bash or awk or perl

we have some data like: 12 0 13 0 20 0 25 1 64 4 77 1 89 100 1201 204 I'd like to get this output: 3 0 5 1 6 4 7 100 8 204 explanation: we have 3 AS(autonomous systems) that have degree of ...
2
votes
1answer
1k views

Counting occurrences in first column of a file

We have this file: 1 2 1 3 1 2 3 3 52 1 52 300 and 1000 more. I want to count the number of times each value occurs in the first column. 1 3 3 1 52 2 This means we saw 1 three times. How ...
4
votes
3answers
88 views

Output numbers from a file in a different order

I have a file that contains: 1 2 3 4 1 3 5 4 8 3 2 1 Each line has a different number of digits. And there are 1000 more like this. I want the output like this: 1 2 2 3 3 4 4 0 1 3 3 5 5 4 4 8 8 ...
0
votes
1answer
221 views

script to convert GB to TB

I have (multiple) files like below list. Few of them has both the values in TB and couple of files in GB. Now if you clearly see the file output there are two rows with Total capacity and Capacity ...
2
votes
1answer
170 views

Delete first lines from a Unicode html file

I have an HTML file that is in UTF-8 format and I want to remove the first five lines from it. I've tried using sed but it doesn't work in this case: sed "1,5d" Result.html>small2 It actually ...
2
votes
4answers
775 views

How do you remove all occurrences of values in one list from another list?

I have a list of symbols such as... wer sfe efo How do I remove all instances of these (unique) symbols from another list of (non-unique) symbols? So in the following list, the lines starting ...
1
vote
1answer
265 views

Using awk/nawk, how to find out max and min contributions and printout those values?

Using awk/nawk, how can I find max and min contributions and print those values? Input file: Name: Phone:1st:2nd:3rd contribution Mike Harrington:(xxx) xxx-xxxx:250:100:175 Christian Dobbins:(xxx) ...
2
votes
3answers
358 views

using nawk, how to sum all numbers in $1, $2, and $3 fields?

using nawk, how to sum all numbers in $1, $2, and $3 fields? 8 6 2 7 3 5 1 9 4 I want the result to be sum = 45
0
votes
4answers
1k views

How to recursively remove all .exe files from all the subdirectories of the current directory?

I have a USB containing important files. However it is infiltrated with some unwanted .exe files (probably virsuses) in each subfolder. Since I am on a Linux machine, the exe files won't affect me. ...
-1
votes
1answer
73 views

Using nawk, how to print the first names for all those in the 916 area code? [duplicate]

Possible Duplicate: Using nawk, how to print all first names containing four characters? Using nawk, how to print the first names for all those in the 916 area code? I've tried nawk ‘$3 ~ ...
-3
votes
1answer
91 views

Using nawk, how to print all first names containing four characters?

Using nawk, how to print all first names containing four characters? I tried nawk ‘/^[[:alpha:]]{4}/{print $1}’ inputfile but didn't work Mike Harrington:(510) 548-1278:250:100:175 Christian ...
1
vote
2answers
1k views

How to extract e-mail or domain from mixed data file in linux

File content: 17541 From Email subscription@test.com Inbound Policy Manager Envelope Analysis Profiler 17541 From Email subscription@yahoo.com Inbound Policy Manager ...
0
votes
2answers
558 views

linux sort -n uniq -c

I have a text file which contains about 50MB of text: valA valB valC valZ valB Whats the quickest way to: cat the file Display the unique appearences
2
votes
2answers
376 views

Grep, find line with minimum x words

Is there a way to find all lines with grep, that contains at least x words?
3
votes
5answers
4k views

How to split a text file into multiple text files

I have a text file called entry.txt that contains the following: [ entry1 ] 1239 1240 1242 1391 1392 1394 1486 1487 1489 1600 1601 1603 1657 1658 1660 2075 2076 2078 2322 2323 2325 2740 2741 2743 ...