Cat

Cat

am 01.02.2008 06:10:16 von sant527

I have a file names spp7 in several directiories CT30 CT31 ........
CT39

Using cat I want to view spp7 file in all the directories at a time

I tried

$ cat CT[30-39]/spp7

It shows

cat: CT[30-39]/spp7: No such file or directory

How can I do it

SimhaRupa Das

Re: Cat

am 01.02.2008 06:29:45 von Ed Morton

On 1/31/2008 11:10 PM, sant527@gmail.com wrote:
> I have a file names spp7 in several directiories CT30 CT31 ........
> CT39
>
> Using cat I want to view spp7 file in all the directories at a time
>
> I tried
>
> $ cat CT[30-39]/spp7
>
> It shows
>
> cat: CT[30-39]/spp7: No such file or directory
>
> How can I do it
>
> SimhaRupa Das

cat CT3[0-9]/spp7

Ed.

Re: Cat

am 01.02.2008 07:40:23 von Stephane CHAZELAS

On Thu, 31 Jan 2008 21:10:16 -0800 (PST), sant527@gmail.com wrote:
> I have a file names spp7 in several directiories CT30 CT31 ........
> CT39
>
> Using cat I want to view spp7 file in all the directories at a time
>
> I tried
>
> $ cat CT[30-39]/spp7
>
> It shows
>
> cat: CT[30-39]/spp7: No such file or directory
>
> How can I do it
[...]

[...] matches *one* character in the specified range. (here 3, 0
to 3 and 9).

cat CT3[0-9]/spp7

would have worked in that case, but in the more general case,
with zsh, you can do:

cat CT<30-39>/spp7

--
Stephane

Re: Cat

am 01.02.2008 11:53:17 von PK

sant527@gmail.com wrote:

> I have a file names spp7 in several directiories CT30 CT31 ........
> CT39
>
> Using cat I want to view spp7 file in all the directories at a time
>
> I tried
>
> $ cat CT[30-39]/spp7

$ cat CT{30..39}/spp7

might be a bash-ism though.

Re: Cat

am 01.02.2008 12:44:05 von Stephane CHAZELAS

On Fri, 01 Feb 2008 11:53:17 +0100, pk wrote:
> sant527@gmail.com wrote:
>
>> I have a file names spp7 in several directiories CT30 CT31 ........
>> CT39
>>
>> Using cat I want to view spp7 file in all the directories at a time
>>
>> I tried
>>
>> $ cat CT[30-39]/spp7
>
> $ cat CT{30..39}/spp7
>
> might be a bash-ism though.

That's a zshism recently added to ksh93 and bash. But that's not
a globbing operator. The above will expand to

cat CT30/spp7 CT31/spp7... CT39/spp7

regardless of whether the files exist or not.

It is different from zsh's

cat CT<30-39>/spp7

which will expand to the list of matching files.

--
Stephane

Re: Cat

am 01.02.2008 13:00:27 von PK

Stephane Chazelas wrote:

>> might be a bash-ism though.
>
> That's a zshism recently added to ksh93 and bash. But that's not
> a globbing operator. The above will expand to
>
> cat CT30/spp7 CT31/spp7... CT39/spp7
>
> regardless of whether the files exist or not.
>
> It is different from zsh's
>
> cat CT<30-39>/spp7
>
> which will expand to the list of matching files.

Well, the OP said that the files are indeed there. Good info though, thanks.

Re: Cat

am 01.02.2008 23:02:22 von Dan Mercer

wrote in message news:916c4e22-b81e-48a7-8e01-92cf2689f5a0@q77g2000hsh.google groups.com...
: I have a file names spp7 in several directiories CT30 CT31 ........
: CT39
:
: Using cat I want to view spp7 file in all the directories at a time
:
: I tried
:
: $ cat CT[30-39]/spp7

[a-z] is an alphabetical range. Your glob matches
CT0/spp7
CT1/spp7
CT2/spp7
CT3/spp7
CT9/spp7

what you want is

$ cat CT3[0-9]/spp7

Dan Mercer

:
: It shows
:
: cat: CT[30-39]/spp7: No such file or directory
:
: How can I do it
:
: SimhaRupa Das