Treat Command Output as a File


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Treat Command Output as a File
# 1  
Old 09-30-2014
Question Treat Command Output as a File

Hi.

Before I've post this question, I have spent hours looking for the solutions but to no avail. Because I think it is possible but I just don't know what is the right keyword to search for.

Ok, basically what I want to achieve is really simple.

It's just that I don't want to write another file because it's merely based on the existing file content.

I have these two files:
Code:
$ pg source.list
CSM_CKC_INFO_20140925.csv@89049445
CSM_CKC_INFO_20140926.csv@74182043
CSM_CKC_INFO_20140927.csv@91001466
CSM_CKC_INFO_20140929.csv@454
CSM_CKC_INFO_20140930.csv@95508536
CSM_CKC_INFO_20141001.csv@67984672
CSM_CKC_INFO_20140928.csv@48531796

and
Code:
$ pg incomplete.list
CSM_CKC_INFO_20140927.csv
CSM_CKC_INFO_20140929.csv
CSM_CKC_INFO_20140930.csv

So, I just want to list out the missing line from incomplete.list against the modified version of source.list - source.lost
Code:
$ pg source.lost
CSM_CKC_INFO_20140925.csv
CSM_CKC_INFO_20140926.csv
CSM_CKC_INFO_20140927.csv
CSM_CKC_INFO_20140929.csv
CSM_CKC_INFO_20140930.csv
CSM_CKC_INFO_20141001.csv
CSM_CKC_INFO_20140928.csv

So, I have this command
Code:
grep -vxFf incomplete.list source.lost > missing.list

So is there any chance for me to avoid writing that new file source.lost which si simply based on this command:
Code:
cut -c 1-25 source.list > source.lost

Thanks a lot.
# 2  
Old 09-30-2014
Do you mean like this?

Code:
cut -c 1-25 source.list | grep -vxFf incomplete.list

This User Gave Thanks to Aia For This Post:
# 3  
Old 09-30-2014
Quote:
Originally Posted by Aia
Do you mean like this?

Code:
cut -c 1-25 source.list | grep -vxFf incomplete.list

Certainly!

Thanks a lot.

Didn't think of passing the it that way.

Anyway, is there any other way? Embrace the command with some brackets for example?

What is I have the 3rd argument to pass in similar way (to be treated as a file)?

Thank you.
# 4  
Old 10-01-2014
Yes what you describe is process substiution and it works like this:

Code:
grep -vxFf incomplete.list <(cut -c 1-25 source.list)

This User Gave Thanks to Chubler_XL For This Post:
# 5  
Old 10-01-2014
Quote:
Originally Posted by Chubler_XL
Yes what you describe is process substiution and it works like this:

Code:
grep -vxFf incomplete.list <(cut -c 1-25 source.list)

Thanks but I got this error:
Code:
sh: Syntax error: `(' is not expected.

# 6  
Old 10-01-2014
This is a fairly new feature and is not available in a lot of shells yet. I know it's supported in the bash shell and ksh93.
This User Gave Thanks to Chubler_XL For This Post:
# 7  
Old 10-01-2014
Quote:
Originally Posted by Chubler_XL
This is a fairly new feature and is not available in a lot of shells yet. I know it's supported in the bash shell and ksh93.
I see.

Thanks for your info.

But I just read somewhere that it is due to posix limited environment.

How do I check if my system supports it or not?

Because I think it's really cool if I could use my script that way.

Thanks.

---------- Post updated at 11:48 AM ---------- Previous update was at 11:40 AM ----------

I am using Bourne shell I guess.
Code:
$ ps
   PID TTY       TIME COMMAND
  1114 pts/te    0:00 telnetd
  1115 pts/te    0:00 sh
 10318 pts/te    0:00 ps

I there anyway that I can do to use this process substitution feature?

Thanks.

---------- Post updated at 11:51 AM ---------- Previous update was at 11:48 AM ----------

I can use
Code:
 grep -vxFf complete.list $(cut -c 1-25 source.list)

But it will read the file content Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Insert title as output of command to appended file if no output from command

I am using UNIX to create a script on our system. I have setup my commands to append their output to an outage file. However, some of the commands return no output and so I would like something to take their place. What I need The following command is placed at the prompt: TICLI... (4 Replies)
Discussion started by: jbrass
4 Replies

2. Red Hat

Command understanding the output file destination in case of standard output!!!!!

I ran the following command. cat abc.c > abc.c I got message the following message from command cat: cat: abc.c : input file is same as the output file How the command came to know of the destination file name as the command is sending output to standard file. (3 Replies)
Discussion started by: ravisingh
3 Replies

3. Shell Programming and Scripting

[Perl] Same entries in file, but treat them different.

Hi, I could use some help with a program that examines a log file. It should output the duration of the steps in minutes. My problem is that there is no end of a step given, only the begin of a next step. Actually the problem is that this line comes 3 times, but marks 3 different events: ... (6 Replies)
Discussion started by: ejdv
6 Replies

4. Shell Programming and Scripting

to take the output of a command to a file

hi , i am using iostat -nmzx 1 | awk '{ print $4 }' command to get the i/o rates of disks. but i want command output in a file , how can i capture , this is some what difficult because command output is keep on changing , any way i have to get total output of the command . please help me .... (1 Reply)
Discussion started by: shankr3
1 Replies

5. Shell Programming and Scripting

Help me to command to output file format.

Dear Master. Help me to command to out put. Ex log. "<?xml version=""1.0"" encoding=""UTF-10"" ?><anova-test-bom> <txid>17251032659</txid> <authentication> <user>admin</user> <password>Amrduoi</password> </authentication> <destination> <msisdn>1111111</msisdn> ... (2 Replies)
Discussion started by: ooilinlove
2 Replies

6. UNIX for Dummies Questions & Answers

getting Output of ls command in a file

Hi I am trying to get the output of ls into a file with names seaparated with comma and no spaces. Here is the content of my dir: ls file1 file2 file3 file4this is what I tried: ls -m > list.txtthe file 'list.txt' looks like: file1, file2, file3, file4, list.txtI... (25 Replies)
Discussion started by: jdhahbi
25 Replies

7. Shell Programming and Scripting

Redirecting output of a command to a file

Hi We are having a requirement where one shell script, say a.sh (which uses Java and connects to Oracle database using JDBC) keeps on running everytime. I created a wrapper (to check whether a.sh is running and if not then to start it) and scheduled it in the crontab. Now all the output from... (3 Replies)
Discussion started by: ankitgoel
3 Replies

8. UNIX for Dummies Questions & Answers

Command display output on console and simultaneously save the command and its output

Hi folks, Please advise which command/command line shall I run; 1) to display the command and its output on console 2) simultaneous to save the command and its output on a file I tried tee command as follows; $ ps aux | grep mysql | tee /path/to/output.txt It displayed the... (7 Replies)
Discussion started by: satimis
7 Replies

9. UNIX for Dummies Questions & Answers

Output of command to 2 separate file?

How would I echo the same results to two files? One is a running log, and the other is a cache, or sort. echo "Hello World" >> /Logs/File1 & /tmp/file2 I would just copy it from one place to the other, but the Log keeps history, where I want the /tmp to hold only stuff per session. I tried... (2 Replies)
Discussion started by: TheCrunge
2 Replies

10. Shell Programming and Scripting

awk - treat multiple delimiters as one

Is there anyway to get awk to treat multiple delimiters as one? Particularly spaces... (6 Replies)
Discussion started by: peter.herlihy
6 Replies
Login or Register to Ask a Question