Thx.
you said it dose not have any sence but still i wnat to understand the meaning of this command.
I did not get what the meaning of this '[^A-Da-f]' all characters that are not in between that range of A to D only or A-D plus a-F? and if this means only A to D range ?
how '^[A-Da-f]' == '[^A-Da-f]'? or the not the same ?
Another thing the grep '^[A-Da-F]' function in the original syntax
(cat f1 >> f2 | grep '^[A-Da-F]')
suppose to look for those letters that r beyond the range in f2 and do what with them?
One more question the option that you offer :
it takes f1 filters the range and then place it at f2?
How dose filter work it takes words that dose not starts with the letters or do not have them at all or just placing the words without the letters leaving empty space?
There is no point running the cat command. It costs you a process and it's much neater to write:-
This will get all lines starting with (the carat ^) uppercase A, B, C or D ; or lower case a, b, c, d, e or f from file f1 and append them to file f2
is this what you wanted to do?
Robin
---------- Post updated at 10:06 AM ---------- Previous update was at 10:00 AM ----------
Ah! An extra reply whilst I was typing.
The difference in the expressions '^[A-Da-f]' & '[^A-Da-f]' are subtle in the text but very different in meaning:-
'^[A-Da-f]' means that the string starts with one of the characters in the range in square brackets.
'[^A-Da-f]' means that the expression is to exclude all the characters in the range.
If you use the form with the carat ^ inside the square brackets, then you are saying get me all records that do not contain any of A, B, C, D, a, b, c, d, e or f.
There is no point running the cat command. It costs you a process and it's much neater to write:-
This will get all lines starting with (the carat ^) uppercase A, B, C or D ; or lower case a, b, c, d, e or f from file f1 and append them to file f2
is this what you wanted to do?
Robin
---------- Post updated at 10:06 AM ---------- Previous update was at 10:00 AM ----------
Ah! An extra reply whilst I was typing.
The difference in the expressions '^[A-Da-f]' & '[^A-Da-f]' are subtle in the text but very different in meaning:-
'^[A-Da-f]' means that the string starts with one of the characters in the range in square brackets.
'[^A-Da-f]' means that the expression is to exclude all the characters in the range.
If you use the form with the carat ^ inside the square brackets, then you are saying get me all records that do not contain any of A, B, C, D, a, b, c, d, e or f.
Is that clearer?
Robin
Thx
No i saw this command in a queze question was what dose it do?
So basically i am not trying to do some thing i just trying to understand.
Could u explain me what the meaning of ^???
difference between if it inside brakets or outside?
Thx
---------- Post updated at 05:10 AM ---------- Previous update was at 05:09 AM ----------
Quote:
Originally Posted by rbatte1
This is known as a useless use of cat
There is no point running the cat command. It costs you a process and it's much neater to write:-
This will get all lines starting with (the carat ^) uppercase A, B, C or D ; or lower case a, b, c, d, e or f from file f1 and append them to file f2
is this what you wanted to do?
Robin
---------- Post updated at 10:06 AM ---------- Previous update was at 10:00 AM ----------
Ah! An extra reply whilst I was typing.
The difference in the expressions '^[A-Da-f]' & '[^A-Da-f]' are subtle in the text but very different in meaning:-
'^[A-Da-f]' means that the string starts with one of the characters in the range in square brackets.
'[^A-Da-f]' means that the expression is to exclude all the characters in the range.
If you use the form with the carat ^ inside the square brackets, then you are saying get me all records that do not contain any of A, B, C, D, a, b, c, d, e or f.
Is that clearer?
Robin
Thx i posted a replay before seeng your explanation very good thanks!!!
---------- Post updated at 05:13 AM ---------- Previous update was at 05:10 AM ----------
Ok i am getting it but what means this ' [A-Da-f]' without the ^ sign?
Thx.
The expression ' [A-Da-f]' as you have typed it (including the space) is to match against strings that simply contain the ranges of characters listed, that is A, B, C, D, a, b, c, d, e or f after a space. The match can occur anywhere on the line, not just at the beginning in this case.
If you have the string without the space, then it simply matches any string that contains any of the ranges anywhere on the line.
Perhaps this would have been better posted in the homework forum where more explanations are often added, even though it's from a "queze". Is that quiz perhaps or a standard exam question even?
Expressions can be very difficult to understand - and I'm still learning all the time, so do persevere.
Robin
Liverpool/Blackburn
UK
Last edited by rbatte1; 03-28-2013 at 07:28 AM..
Reason: Spelling
Concerning "useless use of cat", the title of the topic is "piping commands", so I intentionally left in the cat so there would be a pipe.
Something else to emphasize is that [A-Da-f] stands for a SINGLE character. There is sometimes a confusion that [A-Da-f] can stand for several characters in a row. It's just one character. Of course, that one character could be 'A', could be 'B', etc.
Ditto that [^A-Da-f] stands for a single character, in this case any character that is NOT 'A', 'B', etc.
Even ^[A-Da-f] stands for a SINGLE character. But it requires that the character ('A', 'B', etc.) be at the START of the line. Similarly, [A-Da-f]$ would require that the character be at the END of the line.
Need help in piping commands using xargs
I have several .tar.gz files that I need to list the folder content in a subdirectory.
For example,
a.tar.gz
b.tar.gz
c.tar.gz
The following command works great for each .tar.gz file but it's a pain to run the tar command for each file.
tar -tf... (11 Replies)
can someone please help me fix the below one liner?
what i want to do is run a command, and if that command is successful, pipe the output of the command to another command. i'd prefer not to use any temp files for this.
who -blahblah ; if ; then echo exit; fi | egrep username (2 Replies)
Using the below code I want to find all .sff files and extract them. This works but it seems very cheap. Is there a safer more efficient way to go about this?
#!/bin/bash
G1=(/home/dirone)
find ${G1} -type f -name \*.sff | xargs python /usr/local/bin/sff_extract.py (3 Replies)
This is going to be part of a longer script with more features, but I have boiled it down to the one thing that is presently stumping me. The goal is a script which checks for updates to web pages that can be run as a cron job. The script reads (from a tab-delim file) a URL, an MD5 digest, and an... (1 Reply)
Hi,
I need to use a double grep so to speak. I need to grep for a particular item say BOB and then for each successful result I need to grep for another item say SMITH.
I tried grep "BOB" filename | grep "SMITH"
but it does not seem to work.
I can achieve my desired result using an... (12 Replies)
Hi All,
I am trying to perform the below csh code in Perl, but i am unfamiliar with Perl. Can anybody give me some advice on it ?
Csh Code:
cat filename |grep AAA| grep BBB| awk '{print("already_appended")' (11 Replies)
Is anyone piping commands to ex from scripts?
I.E. echo '%s/change this/to that/\nwq' | ex file.name
I've been using it for years with AIX, Solaris, SGI, with variations ksh and Mandriva and others with pdksh. I've just started using CentOS with ksh and it no longer works. I've tried single... (2 Replies)
I've got a file with lots of commands I want to run in it. They're formatted like so:
cp /path/to/file /path/to/new/file
and on and on and on.
Hundreds of them.
Anyways, I'd like to execute them one at a time, then check what time it is, and repeat this process until 7am.
I can... (3 Replies)
Hi, I am trying to write a program that will pipe any number of programs together like in the linux shell. As an example, the below code tries to execute "cat data | grep int | cut -b 1-10." The problem is that the programs never get executed for some reason. It seems like the first program... (3 Replies)
I am using pipes (specifically piping out) in Perl to put an array from one file into an array in a different file. I can't figure out how to transfer the array. I kow how to open the pipe : open (FILEHANDLE, "| file") or die~
but how do I transfer the array. I think it has something to do with... (1 Reply)