Re: split a file or return shell variable to a program

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



man setenv.

But anyway you could just:

perl -ne '/\S/ and $x++, `echo "$_">>out.$x`' < your_file

On Thu, 22 Apr 2004, vick Julius wrote:

> Date: Thu, 22 Apr 2004 18:33:45 +0000
> From: vick Julius <julius_vick@xxxxxxxxxxx>
> To: linux-admin@xxxxxxxxxxxxxxx
> Subject: split a file or return shell variable to a program
>
>
> Hello everbody
> I have a text file I want to split. The file contains some sentences.
> between sentences I have empty 1 line. I want to split this file and put
> each sentence in a separate file with names 1, 2,3 ...
> do you have any idea to split it such as with awk or split?
>
> Here is my strategy:
>
> I wrote a C program in which I call bash shell script to increment a
> variable...
>
> In the shell I defined the variable k such as:
> $export k=1
> in my bash script file,myFile,  for testing, I put
> echo $k
> let k+=1
> (or this expression k=`expr $k + 1`)
> echo $k
>
> when I run this script file, it gives me
> 1
> 2
>
> the problem is when I called form a C or C++ program, such
> system("echo $k");
> //this gives 1
> system("./myFile");
> // this display
> // 1
> //2
> system("echo $k");
> //here the problem, it display 1 not 2
>
> I want to have the incremented value for k, i.e 2 not the original one.
>
> Do you have any hint?
>
> Vick
>
> _________________________________________________________________
> Add photos to your messages with MSN 8. Get 2 months FREE*.
> http://join.msn.com/?page=features/featuredemail
>
> -
> : send the line "unsubscribe linux-admin" in
> the body of a message to majordomo@xxxxxxxxxxxxxxx
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>
-
: send the line "unsubscribe linux-admin" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Newbie]     [Audio]     [Hams]     [Kernel Newbies]     [Util Linux NG]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Device Drivers]     [Samba]     [Video 4 Linux]     [Git]     [Fedora Users]

  Powered by Linux