Programming :: Unable To Exclude Lines And Bad Filter Within AWK Script
Apr 29, 2010
Looking for some help to fix 2 problems I have in my script. (I�m using bash on cygwin)I have the following source file ($7 does not have data):
Code:
HEADER_1,HEADER_2,HEADER_3,HEADER_4,HEADER_5,HEADER_6,HEADER_7
pattern2,pattern7/Sub data1/Sub data2,pattern8,pattern9,pattern2,pattern2,
pattern3,pattern6/Sub data1/Sub data2,pattern7,pattern3,pattern5,pattern1,
[code]....
In line 5 of the script, that is " {$2 !~ /pattern4|pattern5|pattern6/ }" oriented to delete lines containing pattern4, pattern5 and pattern6 from column 2 it seems not to be working. If I see the output, the line highlighted in red, is present and should not appear, because this line does not contain nor HEADER nor pattern1 nor pattern2.
View 7 Replies
ADVERTISEMENT
May 26, 2010
I'm trying to find all the files in a specified directory that do NOT end in .archived or .error and are older than 30 mins. Currently I have: Code: find /opt/edi/incoming -type f ! ( -name "*.archived" -name "*.error" ) -cmin 30 But I keep returning files that end in those extensions and I'm not sure if I'm using -cmin correcty? If there is a better way to do this (perl, etc) I'm open to options, this is for a nagios check.
View 2 Replies
View Related
May 11, 2011
I'm trying to split a text file into various parts. Everything in between "123" and "break" (including linebreaks) goes into the splitted file.
e.g. using this text file:
This should split into 4 files. However I'm only getting 2 files: one for the line "123break" and one for "123 blah break". The two occurrences that contain linebreaks are being ignored. The .* part of my match should capture linebreaks seeing that I'm using the /s modifier shouldn't it? Even when I use the match /(123 break)/gs it still doesn't capture the first occurrence. I'm using Perl v5.12.3 (from ActiveState) on Windows XP. The text file is also in Windows format.
Code listed below.
The above code generates two files Output_1.txt and Output_2.txt which contain "123break" and "123 blah break" respectively. I want it to generate four files.
View 4 Replies
View Related
Feb 10, 2011
I need to compare 2 files using diff. The problem I've encountered is that I need to exclude certain lines that contain certain phrases. I know that diff supports the -I switch but no matter how I try to form the regexp it doesn't seem to work the way I expect it to. If anyone has used the -I switch before could you please post some examples of how it is used.
diff -I "[skipthisline]" file1 file2 > output.diff
I need to exclude lines that contain the string "[skipthisline]" but I have no idea what syntax is used after the -I switch. Is is supposed to be included in quotes or slashes /[skipthisline]/ or entered without either? I need to include a backslash before each bracket so that it's not interpreted as a set of characters like [a-z] but is instead interpreted as a string. Do I need to use 2 backslashes? "\[skipthisline\]"
Is it sufficient to simply type the string I want to match or do I need to match the entire line in order to exclude it from the output?
.*[skipthisline].*
or
^.*[skipthisline].*$
View 2 Replies
View Related
Nov 24, 2009
How do you remove parts of strings using python? Such as, if I have something like:
Code:
erme1 sdifskenklsd
erme2 sdfjksliel
[code]....
View 3 Replies
View Related
Jun 16, 2010
how to delete string inside the file addresses.txt. The string I want to delete on addresses.txt was on removed.txt. I have a file addresses.txt and it includes the ff format:
test@foo.com
true@fee.com
fee@tik.com
ew@kit.com
test@foo.com
[Code].....
View 5 Replies
View Related
Aug 2, 2010
I'm having trouble figuring out how to list the contents of a directory and exclude any subdirectories.
View 5 Replies
View Related
Apr 25, 2016
I'm trying to configure auditd to monitor "strange" events with apache2 weberver on Wheezy (though same problem occurs on Jessie), tried both with "vanilla" 3.2 and backports 3.16 kernel I am actually using.
Here's auditd rules I have problem with:
Code: Select all-a exit,never -F arch=b64 -S stat -F path=/var/www/server-status -k web
-a exit,always -F arch=b64 -S stat -F uid=www-data -F success=0 -k web
So to recap, I want to log stat syscall failures for www-data user, but excluding some "known" issues, such as that "/var/www/server-status" (after a2enmod status, /server-status path can be accessed for statistics, though apache2 still tries to find physical file for that path and fails).
But the problem is.. excluding does not work.
Here's "auditctl -l" output:
Code: Select all# auditctl -l
LIST_RULES: exit,never arch=3221225534 (0xc000003e) watch=/var/www/server-status key=web syscall=stat
LIST_RULES: exit,always arch=3221225534 (0xc000003e) uid=33 (0x21) success=0 key=web syscall=stat
But when I execute:
Code: Select all# wget -O - http://localhost/server-status
audit.log appears:
Code: Select alltype=SYSCALL msg=audit(1461591557.077:365): arch=c000003e syscall=4 success=no exit=-2 a0=7f1bedab9358 a1=7ffef316ac20 a2=7ffef316ac20 a3=7f1bedab91f8 items=1 ppid=2398 pid=2451 auid=4294967295 uid=33 gid=33 euid=33 suid=33 fsuid=33 egid=33 sgid=33 fsgid=33 tty=(none) ses=4294967295 comm="apache2" exe="/usr/lib/apache2/mpm-prefork/apache2" key="web"
type=CWD msg=audit(1461591557.077:365): cwd="/"
type=PATH msg=audit(1461591557.077:365): item=0 name="/var/www/server-status" nametype=UNKNOWN
type=UNKNOWN[1327] msg=audit(1461591557.077:365): proctitle=2F7573722F7362696E2F61706163686532002D6B007374617274
So, syscall=4 (stat) is still captured. Looks like "path" is known for auditd, but not excluded.
I've tried various rule combinations, for example simpler, more generic one:
Code: Select all-a exit,never -F path=/var/www/server-status
But it's the same.
Sadly man audit.rules and man auditctl does not have "exit,never" examples, only some (sometimes also similarly unsuccessfull) google results.
Could it be that Debian kernel does not support some audit features?
View 1 Replies
View Related
Feb 3, 2010
i have created on folder in my server to upload some regular states. I want that user can modify or upload already stored files. but, should not upload any unwanted files orfolders.for that i want to use "rm" command as auto scheduler (putting this in cron tab.so that all files will be removed except some required files / folders for which this upload facility is activated. users are using secure-shell for uploading data.
View 1 Replies
View Related
Dec 3, 2010
i have a sample that looks like this:
Code:
[schneidz@hyper temp]$ wget -q --output-document=- http://world.needforspeed.com/SpeedAPI/ws/game/nfs-w/leaderboards/events
[code]....
View 2 Replies
View Related
Mar 8, 2010
How can I filter ASCII quotes( ' ) and double quotes ( " ) so that I can replace them with the UTF-8 equivalent?If I copy text from a Word Document(ASCII), and upload it to a web page with PHP. The Database(UTF-8) will replace these racters with incorrect character(s).I need some function that will replace these characters but I don't know how to differentiate the ASCII quotes and the UTF-8 Quotes without (somehow) converting the string to hex, then preg_replace'ing the hex code for the symbol.
View 8 Replies
View Related
Aug 30, 2010
i have file server 1 (filesvr01acess.log) and disc server 1 (discsvr01acess.log) in unix box(say ip adress of the box 10.39.66.81)
Similiarly i have file server 2 (filesvr01acess.log) and disc server 2(discsvr01acess.log) in unix box(say ip adress of the box 10.39.66.82). Now my requirement is write sheel script for ..
1. I need only last 24 hour data out of the file server 1 and file server 2 and then finaly put this data in one new file
2. Similiarly same need for discserver 1 and discserver 2.
FYI, each .log files mentioned above is nicely order as date and time as it is created. I can view through cat or search by using grep comand in unix I am wondering if we can achieve through grep command in unix
View 1 Replies
View Related
Jan 27, 2010
I'm a n00b to both numpy and python. I was wondering what the most intelligent way to write the trapezoid rule function was:
Code:
>>> import numpy as np
>>> a=np.array([1,2,3,4,5])
>>> def mytrapz(vec):
total=0
for i in xrange(0,len(vec)-1):
total+=(vec[i]+vec[i+1])/2.0
return total
>>> mytrapz(a)12.0 This is exactly what I would do in C and I'm sure the for loop is not the fastest way (as is the case for my interpreted langs). Yes, I know there is already numpy.mytrapz... I'm interested in the most efficient way to loop over arrays in such a way that each iteration accesses more than one cell.
View 1 Replies
View Related
Apr 15, 2010
I've got two files. They both contain package names. Is there any way I can go through the package list on one file, and search to see if each package exists in the other file? What I'd want to do, is if the package name is found in the the main file, then go to the next line. If its not found then print that package name to another file.
I know you can use diff, but it doesn't seem to be that straight forward. As I understand it diff searches line by line, so if line one doesn't match line one in another file, then it prints it out. That's not exactly what I want.
I just really need an easy way to filter out the additional packages that exist on a new server. If I have a list of packages that aren't on the original server, then i can just delete them.
Not sure if I've made any sense but there must be a quicker way to do what i need to. It would take me ages to scan manually through the package names in each list, and highlight the ones i dont need.
View 2 Replies
View Related
Feb 10, 2010
I'm building my first BASH programs and I have a hard time. I can't do a search in a folder and filter only script files without extension, the problem is to differentiate the script files from the others. I tried with ls I tried with find and i don't find a way to make it work.
View 8 Replies
View Related
Sep 28, 2010
Code:
// create a filechooser;
JFileChooser chooser = new JFileChooser(cwd);
FileNameExtensionFilter filter = new FileNameExtensionFilter(
"sdf files (*.sdf)", "sdf");
[code]....
This will give 3 filefilters ('all files', 'sdf files' and 'xml files') for a fileopen dialog. Exactly as I want (in alphanumerical order), but XML is the default extension and I like SDF to be the default extension. Research has not revealed solutions; the setFileFilter method sets the primary filter. If I swap the sequence in the code, SDF becomes the default (as I want) but the sequence is wrong (All, XML, SDF).
View 3 Replies
View Related
Feb 21, 2010
I am getting this error "Unknown filter "police", hence option "rate" is unparsable. This is in Linux Kernel 2.6 which is compiled with the "policing" option enabled in Qos (Kernel config). The error seems to be coming from the file tc.c in iproute2/
static int parse_nofopt(struct filter_util *qu, char *fhandle, int argc, char **argv, struct nlmsghdr *n) {
__u32 handle;
if (argc) {
fprintf(stderr, "Unknown filter "%s", hence option "%s" is unparsable
", qu->id, *argv);
return -1;
} if (fhandle) {
struct tcmsg *t = NLMSG_DATA(n);
if (get_u32(&handle, fhandle, 16)) {
fprintf(stderr, "Unparsable filter ID "%s"
", fhandle);
return -1; }
t->tcm_handle = handle; }
return 0; }
This is called from get_filter_kind() which is called from tc_filter_modify(), called from do_filter(), from do_cmd() from main()...all in tc.c. Is this a known "bug" in iproute2+2.6 as the 2.4 Kernel works with the same settings?
View 14 Replies
View Related
May 1, 2011
My script.
This is may script:
Code:
Problem: Output file doest not exclude the values in grep -av
View 3 Replies
View Related
Jul 23, 2010
Is there a command which can be used to run some other command on a few lines from a file or an o/p of some file. (the kind of role that -exec option does for the find command). (I have solved the purpose using a bash loop but would like to know if there exists a command).
View 4 Replies
View Related
Apr 23, 2010
I tried to get a block of lines in awk, but unfortunately it returns output of one line only. I don't state the code here, because it's too short and too poor. What exactly I wanted to do: from file "/boot/grub/menu.lst" get blocks of lines, starting by title and ending by Now I have just
Code:
script="/boot/grub/menu.lst";
OLDIFS=$IFS; IFS=$'
';
[code]....
I want to get every block as one row of array.
View 14 Replies
View Related
Apr 20, 2011
I do a logcat, i got lot of lines, that I filter with a grep, at end, I just got some lines like this:
Code:
I/ActivityManager( 1763): Config changed: { scale=1.0 imsi=732/123 loc=es_ES touch=3 keys=2/1/2 nav=2/1 orien=1 layout=17 uiMode=17 seq=15}
[code]...
View 6 Replies
View Related
Nov 3, 2010
How can I remove all lines which contain A,,,,,, I tried the following sed statements but no luck.
Code:
sed "/A,,,,,,/d file"
sed "/A,,,,,,/d file"
View 6 Replies
View Related
Feb 23, 2011
whichever source code I go through I find these three lines of code written what do they actually mean and what is their function?
[code]...
View 6 Replies
View Related
Jul 1, 2010
I have a large CSV file, tab-delimited with CRLF at the end of each line. Each line should contain 5 fields (i.e. NF == 5) However, there are rogue CRLF characters in the middle of some records, causing records to be split across two lines. I want to scan each line, check the field count and if it's !=5 then join that line to the following line. Example input might be;
Code:
one two three four five
six seven eight nine ten
eleven tw<CRLF>
elve thirteen fourteen fifteen
[code].....
View 2 Replies
View Related
Mar 31, 2011
I'm struggling myself with this problem: I have a file which contains a single column of data
2
.
.
.
45
[code]...
Is there a way to do it with awk?
View 7 Replies
View Related
Dec 14, 2008
I've got a website set up which has a section which is just a bunch of links on the side. But this section of links is on every page of the website. And when I expand and add more links I don't want to have to go to every page and add the new link. Is there a way that I could put all the links into something on CSS (or anything else) that I could just include one line in the HTML? So that when I add a link I'll only have to edit the one file and and then every page will be updated?
View 12 Replies
View Related
May 15, 2011
My problem is like this I have to delete all lines between two pattern match example- suppose below is the content of the file then i have to delete all lines between text1 and text2
...
text1
abc
def
ghi
[Code]....
View 14 Replies
View Related
Mar 25, 2011
i jst want to delete a host entry from httpd.conf the entry for lal.com should be deleted!!
View 14 Replies
View Related
Jan 29, 2011
For example, I have a file called "file" like this one:
type=strongsubj len=1 word=absolve pos=verb stemmed=y priorpolarity=positive
type=strongsubj len=1 word=unique pos=adj stemmed=n priorpolarity=neutral
type=strongsubj len=1 word=absolutely pos=adj stemmed=n priorpolarity=neutral
type=weaksubj len=1 word=taking pos=verb stemmed=y priorpolarity=positive
type=weaksubj len=1 word=friend pos=noun stemmed=n priorpolarity=positive
type=weaksubj len=1 word=usually pos=adverb stemmed=n priorpolarity=positive
type=strongsubj len=1 word=purecolor pos=anypos stemmed=n priorpolarity=negative
type=strongsubj len=1 word=accusingly pos=anypos stemmed=n priorpolarity=negative
I want to add the plural for the noun, for example if find this line:
type=weaksubj len=1 word=friend pos=noun stemmed=n priorpolarity=positive
will add one more line :
type=weaksubj len=1 word=friends pos=noun stemmed=n priorpolarity=positive
where we add "s" for the word friend
I did try to do like that:
<code>
cat file | while read LINE ; do
set -- ${line}
if [[ "${4#pos1=}" == "noun" ]];then
#I tried this line but it doesn't work properly:
v3==$(echo $line |sed 's/$3/$s') #I want to find the third word "word=friend" in that line and add "s" after that word
# I don't know what command to add this new line "$v3" to the file ???
done
</code>
View 12 Replies
View Related
Oct 1, 2010
Every now and then I have to indent the lines in my script to 4 space characters. I generally do it line by line. Is there an automated command in vi using which I can indent some set of lines to desired number of space characters in one go.
View 5 Replies
View Related