0
votes
1answer
62 views

Eliminate need for grep use only awk

I am trying to generate a list of PID's to pass to strace I only want the PID's php-fpm. I can get the correct output by using grep with awk but am looking for an awk only answer. Here is what I ...
1
vote
1answer
107 views

Get some meaning from apache logs with awk and grep [duplicate]

I am trying to have some meaning from my apache log files: I want to parse my access log and have some statistics about 200 status code hits (how many times each of them was hit). So I tried to learn ...
0
votes
2answers
112 views

Script for search string inside the file for every one hour

I need to write a script where the particular string(alphanumeric) should be searched inside the file with every hour for whole day. And the search should not contain the previous hour results. Time ...
0
votes
2answers
40 views

Tinydns data file change ip with bash

I am using tinydns and need to dynamicly change some ip in data file. I want to use bash script for it. For example data file: +sub1.example.org:282.196.222.245:14400 ...
0
votes
3answers
271 views

tail-pipe-awk script, fine on Centos but weird on Ubuntu

I wrote a script on CentOS and now I'm trying to run it on Ubuntu and it is behaving unexpectedly. Here's something like the script, which I run under bash: sudo tail -F ...
4
votes
3answers
298 views

Determine number of unique lines with awk or similar in bash

I am using AWK to read through a custom log file I have. The format is something like this: [12:08:00 +0000] 192.168.2.3 98374 "CONNECT 192.168.2.4:8091 HTTP/1.0" 200 Right now, I have AWK (from ...
0
votes
1answer
71 views

Remove all words that DOESN'T contain a colon [closed]

I have a file with this type of lines: blabla bla:bla whatever what:ever alpha bravo charlie del:ta I only want to keep the words that contain a colon. So the output for the above would be: ...
2
votes
2answers
931 views

How can I add a line break before a set of values going into a bash script?

I've got a set of data piping into a bash script. Here's an example of what that data looks like: "foo1": "Miscellaneous text", "foo2": "More text", "foo3": "blah blah blah", "foo4": ...
7
votes
2answers
825 views

bash sub-string extraction for specified start and end character

For example I have a log file having this entry: [Wed Aug 08 11:39:41 2012] [error] [client 155.94.70.224] ModSecurity: [file ...
0
votes
3answers
181 views

How to join a variable number of lines

I have a file with Feature names and a variable number of usernames below: Feature1 user1 user2 Feature2 user3 I'd like to be able to move the usernames to the same line as the Feature name ...
0
votes
4answers
4k views

remove line break using AWK

I am facing some problem regarding my bash script. Below is my bash code : #!/bin/bash cd /root/Msgs/TESTNEW/new file=myfile.txt var1=$(awk '(NR==30){print $2}' $file) var2=$(awk 'NR>=38 ...
1
vote
2answers
311 views

Using wget and Awk to count similar expressions

I am trying to create a script that uses wget to download a data set and then awk to sort though the file and tell you the most common filter used which is $14 column. So far I have the wget function ...
-3
votes
3answers
684 views

How to pass the output of a command as a variable in a bash script?

I'm trying to pass the output of an awk command as a variable in a bash script, but not having much success so any help is appreciated. homedirectory=$(awk /stephen/ /etc/passwd | awk -F/home/ ...
2
votes
2answers
163 views

awk + perl + get two arguments in to awk syntax

please advice what wrong with my awk syntax and how to fix it ( this syntax is in my ksh script ) and I run my script on linux machine my target is to get from the file.txt only the lines that ...
0
votes
1answer
151 views

cutting relevant portions of a file [closed]

I want to cut some portions of binary file starting from a particular pattern and ending at a particular pattern.How do I do that in linux using bash.Can this be done using sed or awk? I have a file ...
-1
votes
3answers
170 views

linux + generate new file with specific structure from text file what the best option

in my Linux machine I have the file orig-file.txt this file include now 4 fields but they could be less or more ( this file generate by other application ) I need advice - what the best option to ...
4
votes
2answers
908 views

AWK and file names with space in it.

I'm trying to parse files with awk to change their names. Everything went well until im started to do this with files with space in file name. File names are something like 11237_712312955_2012-01-04 ...
17
votes
6answers
5k views

bash/sed/awk/etc remove every other newline

a bash commands outputs this: Runtime Name: vmhba2:C0:T3:L14 Group State: active Runtime Name: vmhba3:C0:T0:L14 Group State: active unoptimized Runtime Name: vmhba2:C0:T1:L14 Group State: active ...
2
votes
4answers
2k views

What command can I use to search sendmail logs for ALL message details involving a specific recipient.

CENTOS 5.x | Sendmail Occasionally I need to search through sendmail delivery logs to find out what happened to a missing message. This usually involves two (or more) steps: STEP 1: Search ...
3
votes
2answers
843 views

Octal representation of file/folder permissions using awk?

We have various of machines here with all sorts of hardware and Operating Systems, most of them do regular tasks with bash that an agent executes. However it came to my attention that some Solaris ...
4
votes
4answers
5k views

Parse and convert ini into bash array variables

I'm trying to convert an ini file into bash array variables. The sample ini is as below [foobar] session=foo path=/some/path [barfoo] session=bar path=/some/path so these become ...
0
votes
1answer
80 views

Parse value of $DatabasePassword from RT_SiteConfig.pm

I'm writing a Bash shell script to backup our Request Tracker (RT) MySQL database on a daily basis. Instead of hard-coding the MySQL database user's password in the shell script I'd like to parse it ...
16
votes
7answers
1k views

Can awk be used instead?

I would like to get the number from rating as output from this # nc localhost 9571 language: language:en_ZA.UTF-8 language:en_ZW.UTF-8 session-with-name:Ubuntu Classic (No effects):gnome-session ...
2
votes
5answers
454 views

How to remove a certain symbol for a bash script

I have a bash script where I get the disk usage, for example 60%. How can I remove the % symbol? Using grep or awk?
1
vote
4answers
722 views

Bash: delete all but most recent n files with prefix x

I have a directory of backups that looks like this: -rw-r--r-- 1 ftpuser ftponly 5610595 May 27 00:01 alpha-114.tar.asc -rw-r--r-- 1 ftpuser ftponly 50559368 May 27 00:04 beta-211.tar.asc ...
1
vote
3answers
436 views

Passing variables problem - Bash

I have a following problem: #!/bin/bash NUM=`cat accounts | wc -l`; for i in {1..$NUM} do account=`awk "NR==$i" accounts`; echo -e "\nAccount: $account\n"; sudo ./backup_maildir $account; ...
1
vote
1answer
378 views

Need help on awk/sed/ perl pattern with regex / grep

Sample file output from grep file1:my $dbh = DBI->connect("dbi:mysql:$database_name", $DB_USER, $DB_PASSWD) file2:($dbc,$rc) = mysql_connect($mysql_host,$mysql_user,$mysql_password); The awk ...
3
votes
1answer
125 views

Unexpected Awk results with sh -c

I am trying to sudo a command that uses Awk, and it looks like awk works differently inside sh -c. echo '1 2' | awk '{print $2}' 2 sh -c "echo '1 2' | awk '{print $2}'" 1 2 Why is this ...
4
votes
5answers
1k views

Is it worth while to learn Awk?

I am decent with bash scripting and I am catching on to regex, and a little sed usage. Is learning awk still worth while with all the alternatives out there. Opinions?
1
vote
5answers
1k views

bash script - print from line N to EOF

I want to be able to print the number of lines from bash as such: Line number (as counted from the top) -> end of the file It seems tail will only count lines from the bottom. Does anyone know how ...
1
vote
3answers
2k views

using awk in a bash script with if

I'm doing a script in which I need to test a string and based on its result I'll decide if I go further or not. The command below works fine (if the string starts with "Clean" it will print 1, ...