General :: Setting Multiple Switches In Grep - Bash Script ?

Feb 21, 2010

I'm working on setting multiple switches in grep.

Here's an example of how to run my script:

would (should) produce the results of this:

Right now i have some code to catch the inputs, using a variable "z":

Code:

Then:

Code:

I'm almost positive that the problem is in the bolded line above (for one thing, it always leaves off the initial "-e"). So basically i want a string that gives me "-e input" and concatenates as many times as necessary.

View 5 Replies


ADVERTISEMENT

General :: Use Grep To Search For Multiple Options?

May 20, 2010

How can I use grep to search for line with either 'res' or 'rep'? i try "grep -e res|rep" or gre -e "rep|rep" but that does not work.

View 3 Replies View Related

General :: Excluding Multiple Patterns From Grep?

Dec 13, 2010

I have to write a script which would search the IP adesseses in a given directory.

Below is my command.

Code:

grep -HwrnI --exclude=*.log '[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}' *|grep -v '/.svn/'

I have to exclude the following from search resluts.

1. Comments

a. Can be starting with /, * or #...

b. Cane be between a line

EX: some text... #comment1

View 9 Replies View Related

General :: Use Grep To Match Multiple Lines?

Feb 3, 2011

I have done this before but i cant really recall now

I have a text file and i want to grep the word "interface" and 10 lines following it. I think there was some switch like grep -A or something ?

View 2 Replies View Related

General :: Grep Multiple Lines From A Text File

Jun 17, 2009

I have a list of words that I want to grep in many files to see which ones have it and which ones dont. in the text file I have all the words listed line by line, ex: list.txt:

check
try this
word1
word2
open space
list ..

I want to grep each line one by one. like I want it to

grep "check" *.log
grep "try this" *.log
grep "word1" *.log .. etc how can I do this?

and maybe write the output to a file.

View 5 Replies View Related

General :: Bash Script: Find, Grep If And Else Programing?

Oct 20, 2010

I am bussy with a litle bash script but i have now a problem.I have a file on the server with every time different text.Somewere in this text the is the following line:PHP Code:<BR><DIV CLASS='itemTotalsTitle'>2 Matching Service Entries Displayed</DIV> I want to make a bash script that replace this line when it says:"0 Matching Service Entries Displayed"To a other text like:"There a no knowing problem(s) on this moment."]If there is a other number than "0" than replace this line with:2 problems have been found on this moment, whe are bussy to fix this problem

View 3 Replies View Related

General :: Multiple Grep Outputs Appended To Single Row Of CSV File?

Sep 12, 2010

how to update a series of values from multiple grep commands outputs to be appended to a single row of a csv file? Work on a linux envir. The values from grep output will be numeric values.

Output sold look like:

1,3,4,5,7,0,5

Each of these values will be odtained from multiple grep commands piped with wc -l Is it possible to update a single row of a csv file if so pleas ehelp me with the command to be used to redirect the output into the csv file

View 5 Replies View Related

General :: Bash - Using Find Or Grep To Locate Filenames With Accented Characters From A Different Encoding System (Windows)

Dec 6, 2010

I tried to tag late onto a question similar to mine on stackoverflow (Find Non-UTF8 Filenames on Linux File System) to elicit further replies, with no luck so far, so here goes again... I have the same problem as the OP in the link above and convmv is a great tool to fix one's own filesystem. My question is therefore academic, but I find it unsatisfactory (in fact I can't believe) that 'find' is not able to find non standard ascii characters.

Is there anyone out there that would know what combination of options to use to find filenames that contain non standard characters on what seems to be a unicode FS, in my case the characters seem to be 8bits extended ascii rather than unicode, the files come from a Windows machine (iso-8859-1) and I regularly need to fetch them. I'd love to see how find and/or grep can do the same as convmv.

[Code]....

View 2 Replies View Related

General :: Proxy Setting In Bash For Using Yum?

Sep 28, 2009

my linux box in the office has an a proxy server to access the internet. i can set this on my browsers. id like to know how i give my shell (bash) the proxy server settings so i can wget,yum install perl modules, etc. on my shell terminal without problems.

i used

Code:

export http_proxy=http://<proxy-server-ip>:<port>

for example

Code:

export http_proxy=http://bsc.aut.ac.ir:8080

and also i did this for ftp. but i doesn't work.

View 6 Replies View Related

Programming :: Grep Multiple Files ?

Dec 30, 2010

I want grep multiple files:

let abc.1.abc.2,abc.3,abc.4

I use grep <pattern> abc.* to read the files. But here grep read files in the order of 1,2,3,4 . I want to to grep the files in reverse order like 1st the abc.4 file will be read and abc.1 file will be last.

Is this possible ?

View 3 Replies View Related

Software :: Grep Current Vnc Server Name Setting?

May 23, 2011

I vnc to a server and the vnc server name will be xxx1:0. Is there a way to grep my current vnc server name setting? Plan to write a script but need to know the current vnc server name.

View 3 Replies View Related

Programming :: Bash: Using Grep To Filter 25 Or Above?

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

General :: Setting Permission For Multiple Users To A Directory?

Feb 25, 2010

I'm having trouble breaking down permissions in linux. Here's the scenario. I have two users: UserA & UserB with each having to ownership and access to directories myDirA and myDirB respectively.

UserA --> /source/myDirA
UserB --> /source/myDirB

I need to set the permissions so that userA can access myDirA and myDirB. There are other users and directories but they should not be able to view outside of their own directories (which is the way it is now). I don't have groups set up for them and I'd rather not change anything else but just the permissions.

rwxr_x_r_x UserA
rwxr_x_r_x UserB

They're read/write/exec permissions are identical.

View 14 Replies View Related

Programming :: Using Grep / Variables In Bash Script

May 10, 2010

I'm trying to write a bash script and I'm having trouble with it.I have a list of DNS entires from a file called zoneExport.txt.Than I want to parse a log file to see if that DNS entry has been queried for. So I'm running a grep command and trying to save it into a variable. What I'm looking for is a variable ($varGrepQ) that has the number of matches for the grep query. I will then run this through an if statement and do some things from there..

But my problem right now is with this grep query. It keeps outputting '0' even when I know there are records in that file and when I run the same query on the command line I get the actual count. My thought is that the $record variable is not passing right.

View 4 Replies View Related

Software :: YUM Install Root - Grep And Bash

Jan 22, 2011

Code:
[liveuser@localhost hd1]$ cat /etc/yum.conf
[main]
cachedir=/var/cache/yum/$basearch/$releasever
keepcache=0
debuglevel=2
logfile=/var/log/yum.log
exactarch=1
obsoletes=1
gpgcheck=1
plugins=1
installonly_limit=3
color=never
# installroot=/home/liveuser/hd1

# metadata_expire=90m
# PUT YOUR REPOS HERE OR IN separate files named file.repo
# in /etc/yum.repos.d
[liveuser@localhost hd1]$ yum list installed bash grep
Loaded plugins: langpacks, presto, refresh-packagekit
Adding en_US to language list
Installed Packages
bash.x86_64 4.1.7-3.fc14 @fedora/$releasever
grep.x86_64 2.7-1.fc14.1 @fedora/$releasever
[liveuser@localhost hd1]$ sudo vi /etc/yum.conf
[liveuser@localhost hd1]$ cat /etc/yum.conf
[main]

cachedir=/var/cache/yum/$basearch/$releasever
keepcache=0
debuglevel=2
logfile=/var/log/yum.log
exactarch=1
obsoletes=1
gpgcheck=1
plugins=1
installonly_limit=3
color=never
installroot=/home/liveuser/hd1

# metadata_expire=90m
# PUT YOUR REPOS HERE OR IN separate files named file.repo
# in /etc/yum.repos.d
[liveuser@localhost hd1]$ yum list installed bash grep
Loaded plugins: langpacks, presto, refresh-packagekit
Adding en_US to language list
Error: No matching Packages to list

Basically when I comment out installroot it says grep and bash are installed but when I change installroot it says grep and bash are not installed?

View 5 Replies View Related

Programming :: Grep For Variable In A Bash Script?

Aug 19, 2010

I've tried every combination of ' " that I have come across in similar threads on the forum but no luck.. I have 2 files

strings.txt: contains a list of numbers, 4 digits per line file.
txt: contains a lines that I want to grep for the strings.

for example:

>cat strings.txt
3214
8746
2411

[code]....

if I echo $i in the loop, I print out the contents of strings.txt If I put 3214 in place of grep "<$i>" file.txt I get "carls phone number is 3214"

View 6 Replies View Related

Programming :: Get Rid Of Unwanted Lines Without Grep -v In BASH?

Jun 9, 2009

I would like to know how I can get the ouput from the following dmidecode command in example 1 to look like example 2 without having to grep -v all the unwanted lines.Is there a way in awk or sed?Example 1

Code:
Processor Information
Socket Designation: Socket 1 CPU 1

[code]...

View 7 Replies View Related

General :: Setting Default Application For Text Files In Bash?

Apr 5, 2011

I want to tweak my linux environment so that when I type a text file name on the command line and hit enter the file should be opened in Vim.

$: /tmp/file.txt

should open the file in Vim. This is similar to what happens on windows (where a text file is opened in notepad.)

View 6 Replies View Related

Programming :: Run Multiple Bash And Php Scripts From A Bash Script?

Jul 25, 2011

I have written quite a few separate bash & scripts and php scripts that up to now I have run from cron jobs. However I have to estimate how long each takes to run, before running the next and so it probably takes much longer than necessary to run them all. They have to run in order.

Now there are so many I am thinking it would be better to have a master bash script that would run one after the other, but I am not sure how to get the master script to wait before starting to run the next script. Is this possible and is there a command that will make the script wait between bash and php scripts , for them to finish, before running the next?

View 5 Replies View Related

Programming :: Bash Script And Grep Inside File?

Apr 2, 2010

What I'm trying to do is grep [mysqld] from inside my.cnf and then add lines inside the file should they not be there. how do i do that?

View 3 Replies View Related

Programming :: Grep Multiple Values In Single Pass Through Log File?

Nov 13, 2010

I have a huge binary log file. There are lets say 4 id's that I want to find in a log file. I know that those 4 id's will be present in the log file and I also know in what order they will be present. I want to find 1st id from the log then 2nd id and then third id and so on..

Simple/inefficient solution is: Loop through the id's and then grep in the log file. Problem with this solution is for each id grep will search from the beginning of the file.

Better/efficient solution would be: Sine I know the order in which id's will be present in the log file. Loop through id's, grep 1st id and then move on to grep 2nd id and so on...this way I can grep all id's in one pass. Is this solution possible ?

I have 500000 + values to find in log files and I have to find efficient solution for it.

View 2 Replies View Related

General :: Bash - Mirroring Of Multiple Directories - Hard Linking

Apr 11, 2011

I have 5 FTP users that upload files (and subdirectories) in their home directory, i need to mirror theese directories beetween them and with a "master" directory (accessible from a 6th user). Files can contain spaces or others special caracters. All the files are in the same filesystem, and i want to use hard link because i don't want to waste 5 time the space of a single file. I tried with find but i cannot handle spaces in it.

View 1 Replies View Related

General :: Bash_history File And Running Bash On Multiple Windows?

May 5, 2011

Despite the history file is unique (~/.bash_history) I see that the multiple bash processes run on different windows are not all updating that file. I presume that the bash is not taking into account this possibility (multiple bashes on multiple windows) and writes thus the history file in a simple straightforward way. This would mean that a number of history entries are lost. I've tried to find information but had no luck so far.

View 1 Replies View Related

General :: Launch Multiple Screen Sessions From A Single Bash Script?

Jul 11, 2011

I've written a script (that doesn't work) that looks something like this:

#!/bin/sh
screen -dmS "somename" somecommand
for i in {0..5}; do
screen -dmS "name$i" anothercommand $i
done

For some reason, if I copy and paste this into a terminal, it creates 7 detached screen sessions as I expect. If I run it from within a script, however, I get only the first session, "somename," when I run screen -ls.

Edit: If the same can be accomplished another way (e.g. with multiple screen windows instead of sessions), I would be open those solutions as well.

View 3 Replies View Related

General :: Bash Script To Read Csv File With Multiple Length Columns

Jul 27, 2011

I've searched everywhere and I can't come up with a good solution. For each line I need to find the average, min, and max. I've seen plenty of solutions where the number of columns is fixed, unfortunately for me these lines can get pretty large. My thought was to read each line individually into an array, loop through the array and find the avg, min, and max that way but i haven't had much luck. I can read each line using a while loop but I'm having trouble with the array part, or perhaps that's not the best solution?

View 14 Replies View Related

General :: Bash Scripts - Comparing Multiple Items Or Conditions Using 'if' Statements?

Mar 12, 2011

comparing multiple items or conditions using 'if' statements? I want to do something if one or more conditions is true, for example:

If a = 1 or b = 1.

I've tried:

[Code]...

View 5 Replies View Related

General :: Create BASH Script To Process Multiple Inputs On Read

May 26, 2010

First post from a very new Linux user....I am trying to create a BASH script that will allow user to provide multiple directory names, Checks if the directory exists and if not create the directory.

I am using the following code:

Which works fine as long as the user enters a single directory name. How can I modify this so it will process all directory names user enters on the read response?

View 5 Replies View Related

Fedora :: Bash Function Alias To Recursively Grep Current Directory?

Feb 14, 2011

This should be a simple thing to accomplish, but I can seem to figure it out. Essentially, I want to have a bash alias or function that will let me recursively grep the current directory. A while back I added this to my .bashrc:

Code:

alias rg="grep -r --exclude=*/.svn/* --exclude=*.swp"

This works fine, (and also ignores any svn and vim swp files), and I can call it like:

Code:

rg foo *

However, 99.999% of the time, I am only interested in searching in the current directory, so the "*" is a bit redundant. Also, I would say 5-10% of the time, I am typing faster than thinking and forget the "*", so grep just sits there trying to read from stdin. It's a pretty minor thing, but ideally I'd like to be able to just type:

Code:

rg foo

I've tried creating a function to handle this:

Code:

function rg(){
grep -r --exclude=*/.svn/* --exclude=*.swp $1 *
}

but it behaves exactly the same as the alias above. escaping the "*" with 's doesn't work, and neither does trying `pwd` (or even a hard-coded path) in its place.

View 2 Replies View Related

Programming :: Grep In Bash Script Returns "No Such File Or Directory", Works Manually?

Feb 25, 2010

To start, I'm writing a script to check a file's date via FTP. Here's the portion that I'm having problems with:

Code:
function checkRemote
{

[code]...

View 7 Replies View Related

CentOS 5 :: Bash: /bin/grep: Cannot Execute Binary File CentOS 5.4

Jun 4, 2011

I am facing problem on executing commands like df -h,ls-l,grep etc in /bin.

it is showing below errors:--
----------------------------------------------------------------------------------
login as: root
root@220.226.102.217's password:
Last login: Sat Jun 4 11:14:20 2011 from 220.227.54.149
-bash: /bin/egrep: cannot execute binary file

[code]....

View 2 Replies View Related







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