How to execute the following commands ?

How to execute the following commands ?

Post by Nico » Wed, 12 Nov 2003 18:32:16



I intended to execute a sequence of command(s) as below :

1. Execute a command, and keep the output of the command (keep it at
buffer/memory not a file),then

2. compare the output of the command with the contents of some file,
and

3. display the diff at screen also append into a file.

perhaps,

bash$ md5sum <file_been_altered>|diff <original_file_checksum>
<output_of_the_command> >> ~/output

although, the above commands is just wrong, but should explain the
situation.

What is the exact and simple way to do it ?  Thanks.

By the way, I am looking for a good links and docs for such stuff to
improve my knownledge in this context. What term should I call this ?
The power of bash tcsh ?? or what ?

Thanks..

 
 
 

How to execute the following commands ?

Post by Ed Morto » Wed, 12 Nov 2003 23:22:40



> I intended to execute a sequence of command(s) as below :

> 1. Execute a command, and keep the output of the command (keep it at
> buffer/memory not a file),then

_buf=`ls`

Quote:> 2. compare the output of the command with the contents of some file,
> and

diff filename - <<!
${_buf}
!

Quote:> 3. display the diff at screen also append into a file.

diff filename - <<! | tee -a outputfile
${_buf}
!

Quote:> perhaps,

> bash$ md5sum <file_been_altered>|diff <original_file_checksum>
> <output_of_the_command> >> ~/output

> although, the above commands is just wrong, but should explain the
> situation.

> What is the exact and simple way to do it ?  Thanks.

> By the way, I am looking for a good links and docs for such stuff to
> improve my knownledge in this context.

You could check the FAQ
http://www.newsville.com/cgi-bin/getfaq?file=comp.unix.shell/comp.uni...
and keep browsing this newsgroup.

  What term should I call this ?

Quote:> The power of bash tcsh ?? or what ?

Just shell programming....

        Ed.

Quote:> Thanks..


 
 
 

How to execute the following commands ?

Post by Marc Olzhei » Wed, 12 Nov 2003 23:32:19


Quote:> bash$ md5sum <file_been_altered>|diff <original_file_checksum>
> <output_of_the_command> >> ~/output
> although, the above commands is just wrong, but should explain the
> situation.
> What is the exact and simple way to do it ?  Thanks.

md5sum <file_been_altered>|diff <original_file_checksum> - | tee ~/output

Zlo

 
 
 

How to execute the following commands ?

Post by Ed Morto » Thu, 13 Nov 2003 00:32:32



Quote:>>bash$ md5sum <file_been_altered>|diff <original_file_checksum>
>><output_of_the_command> >> ~/output

>>although, the above commands is just wrong, but should explain the
>>situation.
>>What is the exact and simple way to do it ?  Thanks.

> md5sum <file_been_altered>|diff <original_file_checksum> - | tee ~/output

tee -a ...

for "append".

        Ed.

Quote:> Zlo

 
 
 

How to execute the following commands ?

Post by Stephane CHAZELA » Thu, 13 Nov 2003 00:47:17


2003/11/11, 08:22(-06), Ed Morton:

Quote:>> I intended to execute a sequence of command(s) as below :

>> 1. Execute a command, and keep the output of the command (keep it at
>> buffer/memory not a file),then

> _buf=`ls`

>> 2. compare the output of the command with the contents of some file,
>> and

> diff filename - <<!
> ${_buf}
> !

It should be noted that this doesn't work if the command output
contains '\0' characters (except with zsh).

Also that _buf doesn't contain the trailing '\n's in command
output. Also that <<! ... ! inserts a trailing '\n'

To hold arbitrary data in a shell variable, you can use
uuencode.

Assuming a POSIX uu(en|de)code:

_buf=`ls | uuencode -m -`

echo "$_buf" | uudecode | diff filename -

(-m uses base64 which is compatible with "echo"; traditional
uuencode format may contain backslash characters that interfer
with echo escape sequence processing, alternative is to use
printf(1) or a here document instead of echo, but printf may not
be built-in and you may end up with a E2BIG error, here
documents create temporary files).

With zsh, you can use:

_buf=${"$(cmd; print .)"[1,-2]}
print -rn -- $_buf | diff filename -

--
Stphane                      ["Stephane.Chazelas" at "free.fr"]

 
 
 

1. Why does the following shell script executes differently than the command prompt


Oh, please don't.  Well, the text/plain is OK, but don't put in that
text/html at the end.

Symlinks.  You're using an automount daemon.  But that doesn't answer
your question.

The probable reason is that $cwd is maintained by csh itself, and
initialized when csh starts.  In the case of the interactive shell, it
started in $HOME, and you did "cd bin", and neither one mentions the
fact that /nfs/machine/usr/me is actually in /tmp_mnt.  But when you
run the script, csh re-initializes $cwd with getcwd() or whatever, and
that call returns the full path, no symlinks.

You can test this: run "csh -f" and see if the new csh "knows" about
/tmp_mnt.

bash has an interesting angle on this: if you cd to a path with
symlink(s) in it, you can get the path either with symlinks (pwd -L) or
without (pwd -P).  This only works because pwd is a bash builtin.

It's often a bad idea to rely on absolute paths (including mount
points) remaining the same across machines.  You're setting yourself up
for writing special cases later....

--
Peter Samuelson
<sampo.creighton.edu ! psamuels>

2. Problem using g++ - converting a pointer from PBYTE to PDWORD

3. Bourne sh: How to Execute Command in Variable following a Pipe?

4. Laptop with PCMCIA

5. Q: find command does not follow symbolic links unless you specify -follow ?

6. Can Matlab run on linux/ppc ?

7. Script to detect user that is executing and execute commands accordingly

8. trouble with nasm + C

9. problem with executing commands from within the shell using a command string.

10. RE : DIFFICULT: Can't execute system command from FVWM, but can from the command line

11. Execute a command based on output of another command

12. how to use execvp() to execute Unix commands with "|" piped commands?

13. executing script commands after su command