I'm trying avoid having a large number of 'if' statements in my script by setting up a variable within 'ksh' which can be expanded depending on parameters passed to the script. The output from the 'cat' command should be able pipe its output into any additional commands on the command line depending on the contents of the variable.
ie The code below should be able to list the complete file, only the executable lines, only the comment lines or be able to count the number of each type of line if required
However when this runs it displays the file on the screen rather than piping the output to 'grep' or 'wc' depending of the parameter passed to the script and then compains about the contents of the variable, which it takes as the name of another file to list
Quote:
cat: | grep -v "^#" : No such file or directory
I have tried a variety of different ways of quoting the contents or escaping the '|' when setting up the variable but none are having the desired effect of piping the output from 'cat' into 'grep' or 'wc'.
I already manage to get the output that i want.. but wat if removing all the pipes and convert it 1 liner with less pipes. My command below can get the ouput that i want. i just want to remove the pipes or less pipes.
#cat file1
us-west-2a running i-3397a421... (2 Replies)
Hey,
Well, we're starting scripting next week for my class, and I have my command done, but I don't actually understand what the meaning is, so I was just wondering if someone could "translate" this in to words so that I might be able to do this better...
command1 | command2 | command3... (5 Replies)
If a code forks 2 childs, what can the values be for the process id's of each of the child? I child pid is supposed to be 0, but what if you fork 2 of them? (5 Replies)
Hello all, I am trying to learn more about programming Unix pipes in C.
I have created a pipe that does od -bc < myfile | head
Now, I am trying to create od -bc < myfile | head | wc
Here is my code, and I know I might be off, thats why I am here so I can get some clarification.
#include... (1 Reply)
Hi
How do I direct the output from ls to for example grep a in C. I am not asking for the whole shell implementation.
If I write ls|grep myfile in the shell. How is the output sent from ls to the input grep. whit int pipe(pipe); We create the pipe. I and I guess we use dup2(old... (4 Replies)
What is the difference between:
cd /tmp
tar -cf - *.txt |gzip > tmp_txt.tar.gz
and
cd /tmp
mknod pipe p
gzip < pipe > /tmp/tmp_txt1.tar.gz &
tar -cf pipe *.txt
Apart from the fact that we have to create the pipe file manually, is there any difference in the performance of the two?... (5 Replies)
Hi,
Can the cd command be invoked using pipes???
My actual question is slightly different. I am trying to run an executable from different folders and the path of these folders are obtained dynamically from the front end. Is there a way in which i can actually run the executable... (2 Replies)