0
votes
1answer
20 views

How to use the awk to print the output

This command nstats gives me output like below. How can I use awk or grep to give me the uptime with only days on it? I cannot use the "" to get the output. HOSTNAME LOAD MEMORY SWAP PROCS ...
-2
votes
2answers
63 views

Trying to count and print song file names using awk

RANK NAME BAND YEAR GENERE DOMESTIC/INTERNATIONAL 206:Reach Out, I'll Be There:The Four Tops:1978:Pop:3/2 207:Bye Bye Love:The Everly Brothers:1950:Classic:3/2 ...
0
votes
1answer
117 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 ...
0
votes
2answers
76 views

sum numbers in different lines in shell

i have 8000 lines similar to this <Flow flowId="1" timeFirstTxPacket="+0.0ns" timeFirstRxPacket="+924100.0ns" timeLastTxPacket="+199984927558.0ns" timeLastRxPacket="+199675473275.0ns" ...
0
votes
1answer
63 views

combining bourne shell and awk

This is my actual file WASfile #!/bin/sh sed -i '/^ *$/d' WASfile sed -i -e '/user=/,/group_1=/{w /tmp/1' -e 'd}' /home/wasdm/WASfile; Script to Add read -p "Press [Enter] to continue for ...
0
votes
2answers
143 views

split a textfile after each n matches to a new file using sed or awk

i tried to split a file in parts of n matches each. The file is just one line and the seperator is '<br>' foo<br>bar<br>.....<br> I just want to split the file in parts, ...
1
vote
1answer
229 views

How to render two columns preserving all whitespace after the first column with awk or alternative?

my output comes in human-readable figures with one space followed by directory names: I am currently using ... awk '{ printf "%-20s %-40s\n", $1, $2 }' input 1G foo 1.5M foo baz 5K foo spaces in ...
0
votes
1answer
116 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
2answers
110 views

Computing average on a list of values for each value

I have a huge file (50k lines) with the following format: 52370581 2116 17996781 4314 47818829 2584 61421045 2158 ... 25145813 2274 The first value can be present multiple times and I want to ...
-1
votes
2answers
482 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
310 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
3k 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
vote
1answer
220 views

error occur when i run awk command write in .sh file and run in cygwin terminal

i have cygwin terminal for run shell script(.sh ) file...it work good..but when i add awk command in shell script and then run Error occur /usr/bin/gawk.exe: error while loading shared libraries: ...
0
votes
3answers
161 views

output the items that showed up 2 times and more

How can I select the ips that showed up 4 times or more , for example here? the input file is 192.168.1.28 192.168.1.100 192.168.1.31 192.168.101.2 192.168.1.31 192.168.11.02 192.168.1.31 ...
1
vote
6answers
348 views

match string in awk

How can I search the file to find the lines that have SRC= , for example here? i mean how can i find source IP address in this file using awk for example Mar 10 03:17:12 ubuntu kernel: ...
0
votes
1answer
653 views

Grep issue (match two strings on same line)

Here I have some grep command which is not working correctly: cat file1.txt: apples Date: Sun, 24 Feb 2013 8:14:06 -0800 peaches melons cherry sky cloud green purple yellow cat file2.txt: apples ...
0
votes
1answer
243 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 ...
0
votes
4answers
2k 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. ...
4
votes
4answers
4k views

Print back-reference in regular expression

I was hoping for a way to make sed replace the entire line with the replacement (rather than just the match) so I could do something like this: sed -e "/$some_complex_regex_with_a_backref/\1/" and ...
0
votes
3answers
457 views

Oneliner for multiline regex s/,\n]/]/g?

Can someone provide a simple one-liner to remove certain line breaks? In vim I use %s/,\n]/]/g This should be possible with a very simple one-liner IMHO, but how?
2
votes
2answers
349 views

What's the best command to use to change a timestamp to readable date when 'tail -f'-ing a log file?

I have a program which logs like this: 1324218770.7644 INFO etc What's the best Linux shell program to pipe that through to change the timestamps to a human readable format like Sun 18 Dec 2011 ...
0
votes
2answers
818 views

Truncate all files in a directory after underscore?

I have a directory with a couple thousand images in it. Most of them have sensible filenames like SD-000.tif SD-001.tif BX-000.tif etc... However probably ~25% of them have names like BX-003_old.tif ...
0
votes
3answers
745 views

Optimize shell and awk script

I am using a combination of a shell script, awk script and a find command to perform multiple text replacements in hundreds of files. The files sizes vary between a few hundred bytes and 20 kbytes. ...
3
votes
1answer
2k views

Reading output of shell command in awk script

I have a text file with a list ip addresses and other information. I am using an awk script to process this list and output various computations. I want to call dig -x from inside the awk script and ...
5
votes
1answer
4k views

Awk doesn't work when inside double quotes

This command doesn't work: ssh $HOST "ls -l | awk '{print $1}'" Above ignores the command "awk" I think it might be because of the double quotes? Also, how would I add another set of double quotes ...
0
votes
8answers
238 views

Unix command to list the portion of the end of a log file from a line containing only hyphens to end of file

I have a long log file where each entry begins with a line containg only hyphens.
0
votes
3answers
250 views

How to use sed or AWK to separate a string (NOT string in files)

How can I separate .sh files into a list? I have tried: ls *.sh | xargs sed 's/\n/ /g' > out.txt The return of ls *.sh is a long string with '\n' in the middle.