Hi I am trying to create a script that will count the number of characters between xml tags and idealy group by these values before returning the variations:
eg
<CONTEXT_1>aaaa<CONTEXT_1>
<CONTEXT_2>bb<CONTEXT_2>
<CONTEXT_2>dfgh<CONTEXT_2>
<CONTEXT_6>bb<CONTEXT_6>
<CONTEXT_1>bbbb<CONTEXT_1>
the result of this would be
<CONTEXT_1> 4...
Hi there,
I'm trying to write a bash script that looks at a directory full of files and categorises them as either plaintext or binary. A file is plaintext if it ONLY contains plaintext characters, otherwise it is binary. So far I have tried the following permutations of grep:
#!/bin/bash
FILES=`ls`
for i in $FILES
do
########GREP...
% cat temp
$$$ hello1
$$ hello2
hello3
## hello4
hello5 $$$
% cat temp | grep "$$$"
Illegal variable name.
% cat temp | grep "\$\$\$"
Variable name must contain alphanumeric characters.
%
I want to grep for $$$ and I expect the result to be
% cat temp | grep <what should go here?>
$$$ hello1
hello5 $$$
%
To differentia...
I'm playing with bash, experiencing with utf-8 encoding. I'm new to unicode.
The following command (well, their output) surprises me :
$ locale
LANG="fr_FR.UTF-8"
LC_COLLATE="fr_FR.UTF-8"
LC_CTYPE="fr_FR.UTF-8"
LC_MESSAGES="fr_FR.UTF-8"
LC_MONETARY="fr_FR.UTF-8"
LC_NUMERIC="fr_FR.UTF-8"
LC_TIME="fr_FR.UTF-8"
LC_ALL=
...
I have a file and a list of string pairs which I get from another file. I need substitute the first string of the pair with the second one, and do this for each pair.
Is there more efficient/simple way to do this (using Perl, grep, sed or other), then running a separate regexp substitution for each pair of values?
...
Hello people, I'm having a problem with regex in using the command sh cute, the problem is that I want to show all processes that start with g and just show the command, but do not know, help me please?
To do this I use the command:
ps aux | grep g
but this show all process who contains the letter g and i need who start with g
and c...
Is there a way to use grep or awk to find text files that contain both e.g. "a" and "b" but in this case "a" and "b" are on different lines?
...
I know I can "probably" fix them by using "flip -u" (cygwin flip) which basically removes one of the 0xd's leaving the file with DOS style line endings (0x0d 0x0a) (of course, technically speaking this might be considered a bug!).
But the other side of it is that i'd like to do this selectively, ensuring that what I'm fixing really is a...
I have a simple log file which is very messy and I need it to be neat. The file contains log headers, but they are all jumbled up together. Therefore I need to sort the log files according to the log headers. There are no static number of lines - that means that there is no fixed number of lines for the each header of the text file. And ...
I need to find ALL files that have multiple keywords anywhere in the file (not necessarily on the same line), given a starting directory like ~/. Does "grep -ro" do this?
(I'm using Unix, Mac OSX 10.4)
...
I'm trying to regex process id's based on parts of a process name. It seems to work if I only do a single word, but it fails when I try to do something like: find me any process with path /beginning ** /endswiththis/
Here's what I have so far:
QUEUE_PID="$(ps -ef | grep endswiththis | grep -v $0 | grep -v grep | awk '{ print $2 }')"; ...
Hi,
I need to find all instances of 'filename.ext' on a linux system and see which ones contain the text 'lookingfor'.
Is there a set of linux command line operations that would work?
...
I'm using cucumber to run some tests. It colorizes its output using ANSI escapes. This is great, but currently its producing more output than I care about, and shoving things I do care about off the screen. There doesn't seem to be a way to eliminate the other lines from within cucumber, but I can pipe the output through grep to pare ...
i have following pattern
parts=/a,1mb,/b/c,2gb,/zee/last,-1 #general form on next line
^parts=path1,size1,...,lastPath,-1$
I want to replace all $path1,$size1 except $lastplace,-1 with $newPath,$newSize i.e.
parts_new=/p,2mb,/q/r,5gb,/zee/last,-1 #general on next line
^parts=newPathX,newSizeX,lastPath,-1$
I figured how to do it usi...
Hi there! I have a log file which needs to be properly formatted into a readable format. However the text file has no static number of lines or fixed primary values and has random number of spaces but has only a log file header which can be used to pin point the start and end of each time the application logs.
An Example of the log file...
cat 1.html | grep "<title>" > title.txt
This wont work ..
please tell the best way to grab the title of a page using grep or sed ..
Thanks .
...
How can I implement grep of Unix in Perl? I tried to use Perl's built-in grep. Here is the code which is not working:
$pattern = @ARGV[0];
$file= @ARGV[1];
open($fp,$file);
@arr = <$fp>;
@lines = grep $pattern, @arr;
close($fp);
print @lines;
And by the way, i am trying only basic grep functionality not full featured and secondly ...
@ver = $session->cmd("sh conf");
The variable here is ver, which has the configuration file, that is, it has more than one line. So how to take an output of each line of the ver variable without putting it in a loop?
...
Hi all.
Using PHP, how to find all the files in the whole system (I am using ubuntu) which contain string errorlog.
I tried exec() and grep but it is taking just one occurrence. Thanks.
...
I have file like this which contains 5 columns. But some rows in my file have 4 columns by mistake, for example in this file at the 5th and 6th rows, you can see that the second column is missing. I want to replace the missing 2nd column with a blank space without disturbing other rows in my file with field separator ",".
11111,5323,62...