[...]
At the moment, I use this command to avoid multiple lines command:
But the issue here is, the rm -f source.temp is only executed whenever the missing.list is not 0 in size.
Please help.
Thank you.
If that is an issue then try:
---------- Post updated at 09:30 PM ---------- Previous update was at 08:49 PM ----------
I wonder if this will produce the same result you are looking for:
---------- Post updated at 09:30 PM ---------- Previous update was at 08:49 PM ----------
I wonder if this will produce the same result you are looking for:
Thanks a lot!!
Yep this awk -F"@" 'NR==FNR {a[$1];next} {if($1 in a){next;}print $1}' source.list complete.list works! And it is so flexible and thus the difference could be done both ways. Thank you so much.
The temp file removal also works. Thanks.
So, could you explain both of the codes? What does the [ -e source.temp ] acts for?
which will try to delete source.temp regardless of any other previous command, however, that would display an error if it was not found.
[ -e source.temp ] (notice the spaces after [ and before ], very important) is test. (take a look at man test), -e evaluates to true if exists, so if that is true then continue to rm -f, avoiding the error message.
Awk
-F"@" make the field separator an `@', that takes care of the format of source.list, dividing each line into two fields, before the `@' and after the `@'
NR==FNR {a[$1];next} this part is only for the first file, in this case source.list. The build-in variable NR is set to the total number of records found from all files, the build-in variable FNR is only the number of records in the current reading file, so as long as both are the same, we are reading only from the first file, if so perform the instructions on the first set of {a[$1];next} which only keeps an array named `a[name of the field]' and skip the rest of the instructions.
Now, we have the whole first file indexed in memory.
{if($1 in a){next;}print $1}'The rest is just an evaluation for the second file, if any of the records are seen already, do nothing (skip to next), otherwise, display it because is missing.
Last edited by Aia; 10-02-2014 at 02:39 AM..
Reason: more explicit
Maybe my suggestion is outside your main concern on temp files, but you can also try this.
Both input files should be sorted
join is a very powerfull tool that helps you process files as databases , provide they are sorted.
This User Gave Thanks to blastit.fr For This Post:
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)
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)
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)
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)
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)
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)
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)
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)
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)