General :: Grep Extended Regez In For Loop?

Jun 3, 2010

I'm trying quickly dig through our VPN logs for a list of class A ips , and I'm having trouble. I have a file with a list of numbers, one per line. I'm wanting to incorporate each number into an extended regex:

Code:

for i in `cat ips`; do zgrep -E '[[:space:]]$i(.[0-9]{1,3}){3}[[:space:]]' vpn1/2009.08.20.log.gz; done

If I substitute one of the numbers in for $i, it works for that number. For example:

Code:

for i in `cat ips`; do zgrep -E '[[:space:]]58(.[0-9]{1,3}){3}[[:space:]]' vpn1/2009.08.20.log.gz; done

I think the loop is passing literally "$i" to zgrep instead of its value due to the tics, and I can't figure out how to resolve this. I can't remove the tics b/c zgrep doesn't like that. Putting a backslash in front of $i doesn't work.and the number loop seems to be working fine:

Code:

for i in `cat ips`; do echo $i; done
1
14
27
43

[code]....

View 3 Replies


ADVERTISEMENT

General :: Using 'find' And 'grep' In A For Loop?

Mar 23, 2011

I have a server hosting 100+ websites. I need to quickly identify which websites are configured with a database. There are way too many to manually check every website for a PHP file with a database name. So, I created a list of all databases from MySQL and put them in a text file. I then exported the text file to a shell variable and used it in a for loop.

bash variable

Code:
DBLIST=`cat dblist.txt`
Example of $DBLIST

Code:
db1 db_testing2 database_clientname production words4cheap
for loop

Code:
for db in $DBLIST; do find . -type "f" -iname "*.php" -exec grep -i $db '{}' ; -print; done
Note: my find statement starts searching at . which is the directory that contains all of my websites and their data, each website is setup in a sub directory, identified by it's domain name.

Example: I'm in /var/www. Beneath /var/www are a list of directories:

[URL]

However, this is taking too long (it's been running most of the day) and I was wondering if there wasn't an easier way to accomplish what I'm trying to achieve?

View 4 Replies View Related

General :: For Loop Or While Loop To Read The Fields Of A File?

Sep 1, 2010

I have a mytext file with month and year as two separate fields. likemytext fil

08 2010
09 2010
10 2010
........
........
........

I want to read the values of each field i.e., month and year into an awk script.

View 10 Replies View Related

Programming :: Input File - Grep Within Grep

Nov 22, 2010

I need to kind of grep within grep. My input file would be something like:

[Code]....

and I need to find the first occurrence of hello before MY PATTERN (hello 9008 in this case), so the output should be:

[Code]....

View 4 Replies View Related

General :: Can't Use The Tv As An Extended Desktop

Nov 1, 2010

I recently installed a DisplayLink usb adapter on my desktop to use my tv as a second monitor because it had no vga socket, it works great only I can't use the tv as an extended desktop. The 2 monitors work perfectly seperately but I want to be able to use one as the main screen and the other as an extension. I am running Maverick on a P4 2ghz dell optiplex 260 and the output to tv is hd.

View 2 Replies View Related

General :: Creating An Extended Partition

Mar 14, 2011

I'm trying to create an extended partition. In GParted, I shrunk the size of the existing partition and now want to create a new EXTENDED partition in the free, unallocated space. GParted only lets me create a PRIMARY partition. What am I doing wrong here?

Here's what I've got right now:

You can actually ignore the flag for the swap as "boot." That was me just messing around trying to get it to work. I've removed that flag. Not sure how the question of boot affects all of this...maybe it factors in somehow.

View 2 Replies View Related

General :: Partitioning - Primary And Extended ?

Oct 14, 2010

I am installing opensuse on my laptop. Dual boot with Windows 7. Two partitions are already taken by windows. I am confused about extended partitions. I know I will need one because I can only have 4 primary partitions.

Here are the partitions I want:

Is there a certain order to create these? Does it matter which ones are primary partitions and which one are part of extended partitions?

View 4 Replies View Related

General :: How To Use Extended ASCII Characters

Apr 6, 2010

How can I use extended ascii characters, like ALT + 2 + 0 + 0 for instance? I'm using some of those characters for my passwords for online accounts made under MS Windows and it seams I'm unable to use them in Slackware 13. For instance: if I type ALT+2+0+0 in Pidgin there is no character displayed and if I type in the Terminal the same thing, it will replace my shell prompter (sasser@HOSTA:~$) with (arg: 200):
sasser@HOSTA:~$
(arg: 200)

View 2 Replies View Related

General :: Safe To Format Extended Partition?

Aug 6, 2010

My new Debian box is running well and stable enough for me to decide to swipe out WindowsXP altogether. I have a 40GB HDD, which has the following partition scheme (after Windows was removed and hda1 was converted to Linux native type)

Code:
Device Boot Start End Blocks Id System
/dev/hda1 * 1 1762 13313159+ 83 Linux
/dev/hda2 1762 5168 25756889 f W95 Ext'd (LBA)
/dev/hda5 1762 3985 16813408+ b W95 FAT32
/dev/hda6 * 3986 5018 7809448+ 83 Linux
/dev/hda7 5019 5168 1133968+ 82 Linux swap / Solaris

As you can see, my Linux is in the 2nd logical partition hda6 which contained in the extended hda2. The 1st logical partion hda5 is the one I want to erase the data and convert to Linux filesystem in order to have more space. (Yes I can mount it ntfs-3g and use it without any problem, but I just want to say farewell to as many things Microsoft as possible) . What I'm worried about is whether it's safe to do that, without damaging the extented partition which contains the root file system for Debian.

View 3 Replies View Related

General :: Cannot Create Extended Partition For Ubuntu

Jan 26, 2011

Okay so first of all, let me give you a background info.I have an HP Mini 311 with a 250GB hdd and 2GB Ram. I have successfully setup a tripple-boot with SnowLeopard/Win7/Ubuntu10.10.Okay so

First, using "Disk Utility," I format the OSX partiton to Extended(journaled) and install OSX accordingly.
Second, I install Windows 7.
Third, I use Netbookinstaller to install Chameleon 2.0 onto the OSX partition.
Fourth, using DIskPart.exe i set the Win7 Partition(#3) as active and then run the Repair(and Restart) option in the Win7 USB install media, to fix some boot error I do not know much about. Then use"DIskPart. exe" again, to set the EFI partition(#1) as active partition again.I now have a fully operational dual-boot with SnowLeo and Windows 7.

I setup a triple-boot with SnowLeo/Win7/Ubuntu10.10 by using GParted to add and format 2 additional partitions. The first formatted Ext4 for Ubuntu to be installed onto and the second i set about 4GB as "Swap" area.Then i just install Ubuntu with the Grub bootloader being installed onto the same partition as Ubuntu.I now have a fully operational triple-boot with SnowLeo, Win7 and Ubuntu.So I saw this link about creating an additional "storage" partition, on a dual-boot system, and setting it up so that Windows 7 and Ubuntu can share the same files automatically.

I really want to set this up on my triple-boot system, and here is the problem i run into: Simply adding another partition, messes up my windows 7 boot entirely. And i figured out the cause of this might be due to harddrives only being able to handle 4 primary partitions. So i figure that if setup Ubuntu and the Swap-area into an Extended Partiton, this would solve all of my problems.I cannot figure out how to setup an extended partition on my harddrive without messing something use up irreparably. This is only my second

View 14 Replies View Related

General :: Creating Extended Partition - RHEL 5.4

Apr 18, 2010

I'm following the book RHCE book (5th edition) by Michael Jang. On the exercise on pg.140, creating partitions, I've created /boot (hda1), swap (hda2) and / (hda3). So far so good.

Next, I'm supposed to make an extended partition, containing the rest of the disk. So this should be hda4, right? But when I try to create either an LVM, or RAID partition, it creates hda4 AND hda5 under hda4. Why is that? Am I doing something wrong? The book next asks me to create /var as hda5, so if hda5 is already created automatically above, how am I supposed to create /var?

View 7 Replies View Related

General :: Getting Extended Ascii (chars > 127) To Work

Mar 4, 2011

I have an application where the client is written in Visual Studio (C#), run on PCs, and the server end has traditionally been SCO. We're now migrating to Linux. I can, for example, input "Test This" in a text box on the client, and when the server end is SCO, it is able to 'accept' the character sent to it from the client. When I try this same example on Linux, that character (hex D1) does not 'make it' from the client to the server.

The problem is not on the client, and I have verified that the telnet connection is in fact passing these extended characters, but they are not recognized properly by the Linux server.In researching this, I've played with setting the LANG environmental variable from LANG=en_US.UTF-8 to several of the other possible values found in /usr/lib/locale, for a european locale (the end user is actually in Spain), and these 'euro' characters are still not handled properly in my application.Would anyone be able to point me to any specific env variable settings, and/or anything else that would resolve this issue?

View 6 Replies View Related

General :: Partition On An Existing System - Extended Not Being Used

Jul 14, 2011

I have a 120GB HD that I installed my linux-mint distro to and have been using for a while now, maybe a year or so. However, it has been running great so I haven't paid much attention to the actual install. Recently, I have been getting notifications of very low disk space remaining. I ran gparted and discovered that there is a very large extended partition that doesn't appear to be mounted. Can I just boot into a terminal, set a mount point and be on my way or will this hurt my existing installation? What is the safest set of steps to mount this partition since it looks to be the swap space as well?

Code:
Here is output of fdisk for the drive:
Disk /dev/sdb: 122.9 GB, 122942324736 bytes
255 heads, 63 sectors/track, 14946 cylinders

[Code]....

View 5 Replies View Related

General :: Adding Unallocated Space To Extended Partition

Aug 13, 2011

My setup is as shown in the image below,i have 170G of unallocated space which id like to add to my Extended partition so that i can create logical partitions.I can only create one primary partition now of 170G which i don't need.Can i boot my machine off a live-cd and a run a gparted and add the unallocated space to the extended partition?

View 9 Replies View Related

General :: Diffenrence Between Primary - Logical - Extended Partition ?

Jun 24, 2011

The difference between primary or logical and extended partition in disk management in redhat linux

View 1 Replies View Related

General :: Possible To Move Ubuntu Primary Partition To Logical / Extended?

Nov 5, 2010

I'm currently dual booting Windows 7 64bit and Ubuntu 10.10 each on primary partitions. Then on the other 2 partitions I have the manufacturer recovery partition (which I am not sure I should remove...), and then a partition for storage and files. Now I want an Arch Linux installation on the hard drive, but obviously I cannot create a new primary partition because I already have 4. I found out that linux can run from a logical partition (which you can have multiple of)..However I do not want to format my Ubuntu partition and I'd prefer to keep the data on there all intact. Is there a way to move my Ubuntu installation (on the primary partition) to an extended partition where I could put multiple logical partitions for multiple linux installations?

View 2 Replies View Related

General :: Extended Desktop Virtual Screens And A Usb2vga Adaptor

Jan 16, 2011

OS Linux Mint 10, Intel graphics, SIS usb2vga adaptor.

I have three screens. The netbook screen with the extended desktop onto a vga screen and a third screen connected to a usb2vga adaptor.

The extended desktop screens without the usb2vga adaptor works perfectly. I can maximise applications to either screen perfectly without them spreading across both screens. As soon as I connect the third screen via the usb2vga adaptor maximising an application causes it to spread across both screens yet the third usb2vga screen has it's own virtual desktop environment.

I have tried numerous versions of my xorg.conf file that I have generated to incorporate the usb2vga adaptor to make this work and regardless of what xrandr commands I send including changes to the gconf settings nothing seems to solve the issue.

It seems odd that I can create a panel and position it left, right, top or bottom of the second monitor of the extended desktop and it sticks to the screen dimensions yet I can't get any application to do the same when there is a third screen connected through the usb2vga adaptor.

I don't use Compiz, it crashes my system and I don't want separate workspaces I want the extended desktop with the two separate virtual screens to fit on the two separate screens that form part of the extended desktop.

With Xinerama deprecated what other options do I have.

View 5 Replies View Related

General :: Extended Partition Is No Longer And It's Full Of Important Stuff

Apr 19, 2010

I'm sure I've done this before and never ran into trouble so it's not like I wasn't thinking, just something went wrong this time and I'm screwed. I'll post a fdisk -l to show ya what I mean.

[root@localhost ~]# fdisk -l /dev/sda
Warning: invalid flag 0x0000 of partition table 5 will be corrected by w(rite)
Disk /dev/sda: 1000.2 GB, 1000204886016 bytes
255 heads, 63 sectors/track, 121601 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x624aa2e0

[code]...

Well I tried to install Pclinuxos 2010 to the same partitions as Mint 7 and basically just over write it (this I have done before) but this time Pclinuxos says there is a bad block and it can't copy files to / (sda7) I didn't think much of it at the time and thought I would try to install it (Pclinuxos) on a separate 100 gb usb drive and it was a sucessful install.

After booting Pclinuxos I try to access my 1TB sda hard drive and I can ony access sda1 .....when I look at /dev/sda in gparted is shows the whole disk as unallocated.I have done nothing at this point in time other than what I just said because I am very afraid of loosing all my pictures and everything else on that disk....and for those that will say always back up ....if ya think I'm not kicking myself right now your dead wrong......

View 7 Replies View Related

General :: Opensuse 11.3 Nvidia Gtx260 Dual Display - Xinorama - Extended Desktop Mouse ?

Jan 14, 2011

Recently installed OpenSuse 11.3 on my system, Setup dual monitors w/ the latest Nvidia driver from Yast repo : download.nvidia.com

Initially twin view ( same desktop viewed on both monitors ) worked no problem

Once xinorama was enabled to extend the one desktop across both I encountered a mouse issue.

Main monitor is on the right, 2ndary on the left... When I drag the mouse from the right monitor over to the lest.. the cursor appears to get stuck on the left monitor's right hand edge.. it flickers as i move it around...

If I drag the mouse to the right a few whole mousepad lengths it will come back to the right...its like fighting to bring it back..

View 1 Replies View Related

General :: Cd Error From For Loop?

Nov 10, 2010

./test.sh: line 3: syntax error near unexpected token `cd'
./test.sh: line 3: `cd $f'
--------------------------------

[code]....

View 1 Replies View Related

General :: How To Use Grep

Apr 7, 2011

I need to find file from ls - l by using grep and certain regexp.

In particular I need greep to see certain file ending, like let's say .txt but only using regex.

So it should be something like

ls -l | grep '^.+.txt$'

But that doesn't seem to work for me.

View 1 Replies View Related

General :: Syntax Error In If Loop?

Mar 7, 2011

I have a requirement to check the following conditions..If my folders are not A and B then list files in the directory else no listing the filesso my if loop is some thing like this.

Code:
if [ $dirName = "C" && $dirName != "A" && != "B" ] then
ls -la

[code]....

View 1 Replies View Related

General :: Bash For Loop Not Working?

Apr 21, 2010

I have bash 4.0. I used the following for loop example, but all it outputs is "{1..10} instead of the actual numbers one through ten. why?

Code:
for a in {1..10}
do
echo -n "$a "
done

View 5 Replies View Related

General :: Cannot Add Fractions In Loop Using Bc In A Script?

Feb 11, 2010

i have tried a lot to add floating values in while loop using bc, but no sucess!!!

script is :
read a1
read a11

[code]....

View 5 Replies View Related

General :: Shell Programming Using While Loop

Jun 28, 2010

I am trying to do some shell programs. I tried some sites regarding the while loop, they give the structure as:
Code:
while [ n1 -lt 500 ]
do
echo $((n1+100))
done

But the below code also worked for me:
Code:
while ((n1 > 500))
do
echo $((n1+100))
done
By using (( )) I could use while, for. But the documentations didnt follow this way. I mainly use this for datastructure programming.

View 4 Replies View Related

General :: Loop Detected When Resolving The Name From Dns?

Apr 26, 2010

The problem of loop detected when resolving the name from dns.Why the problem of loop detected comes when name is resolving from dns.

View 4 Replies View Related

General :: Getting The While Loop To Execute In The Ssh Command?

Jun 15, 2011

I am having trouble getting the while loop to execute in the ssh command:ssh $USERID@serverX "while read line do echo $line done<$list_dir/cost_feed.lst.old"Error:bash: -c: line 1: syntax error: unexpected end of fileI have managed to use simpler commands with ssh like:ssh $USERID@serverX "pwd; cp x y"I expect that I need to add some combination of escape characters or semicolons

View 3 Replies View Related

General :: GREP On Words With 2 Or More Z's?

Dec 21, 2010

I need to grep a dictionary file.Only the words that contain 2 or more z's and only 1 b needs to be listed.

View 1 Replies View Related

General :: Grep Not Working?

Jul 15, 2010

I am trying to grep for A records in a bind zone file but I am failing.I am trying: grep "s+As+" db.domain.comBut there are no results.

View 12 Replies View Related

General :: How To GREP String

Jul 29, 2010

Today, i checking my error log of Apache. I have look many IP brute scan URLo, i collect, export that to ip.txt and i need grep IP with connection >=8I don't know command to solve that. Example ip.txtQuote:

101 210.13.73.30
161 58.210.77.98
164 115.168.71.87

[code]....

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved