analyzing data from more than one file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting analyzing data from more than one file
# 1  
Old 01-25-2009
analyzing data from more than one file

Hello,

I have two data (.txt) files which I need to do some operations on them simultaneously. for example:

file1:
word11 word12 word13
word21 word 22 word 23
word31 word32 word33

file2:
word11 word12 word13
word21 word 22 word 23
word31 word32 word33

I need to see if each word in the first column in the first file exists in the second column in the second file. This is not the problem, the problem is to receive both of the files to the same script. Is it possible?

I thought about two options, but none of them worked;

first option:
I wrote a main script and pipelined the first file to a secondary script (let's call it scr1), and pipelined the other file to another secondary script (let's call it scr2). In scr1 I moved the word I needed into a var, and in scr2 I did the same thing to the word I needed in the second file. The problem is that now I can't compare between these two vars, because they're in different scripts. Is there a way to do that?

second option:
I wrote a main script and pipelined the two files to a secondary script, but I can't do
set line1 = ($<)
set line2 = ($<)
(obviously)
and also, it joins both of the files together so I can't refer to both of them, because it's one file now.

Is there another way to do this? And was the beginning of one of my ways somehow correct?

I have to use C-Shell and I can't use sed and awk.

Thank you so much if you're able to help me.
Shira.
# 2  
Old 01-25-2009
Quote:
Originally Posted by shira
I have to use C-Shell and I can't use sed and awk.
Shira.
Why not? Is this a homework assignment?
Homework questions are not allowed, please read our rules.

Regards
# 3  
Old 01-25-2009
I'm using c-shell since I have background in ansi c and it's easier to comprehend, that's it. Smilie
# 4  
Old 01-25-2009
Quote:
Originally Posted by shira
I'm using c-shell since I have background in ansi c and it's easier to comprehend, that's it. Smilie

You'll find scripting much easier with a POSIX shell, and you'll find far more people ready to help, and much more documentation online and in print.

Top Ten Reasons not to use the C shell
Csh problems
Csh Programming Considered Harmful
# 5  
Old 01-25-2009
Thank you for your response!
The thing is that I've almost finished my script, I just have this problem which I cannot overcome. If there's anyone who is able to help, I would really appreciate it.
# 6  
Old 01-25-2009
Quote:
Originally Posted by shira
Thank you for your response!
The thing is that I've almost finished my script, I just have this problem which I cannot overcome.

Perhaps you have run up against one of the deficiencies of csh?

If it's not homework, why can't you use sed or awk?
# 7  
Old 01-25-2009
When you want to study a language to its depth, you have to have strong basic skills and then you can use the shortcuts. Like when I studied ansi c, I didn't use all the <string.h> functions, I wrote them by myself.
And as you can see, I cannot solve this particular problem, so I have to learn this in order to progress.
Also, cshell is a basic script language. I will move on to more advanced languages when I feel I have enough knowledge.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Homework & Coursework Questions

Lex: analyzing a C file and printing out identifiers and line numbers they're found on

Florida State University, Tallahassee, FL USA, Dr. Whalley, COP4342 1. The problem statement, all variables and given/known data: Create a lex specification file that reads a C source program that ignores keywords and collects all identifiers (regular variable names) and also displays the line... (3 Replies)
Discussion started by: D2K
3 Replies

2. Programming

Difficult in analyzing an algorithm

Hello, I was reading Heuritics text and came across an algorithm below. Finding hard to analyze it can any one help me out below... How to analyze if I take say no. of types are 5 and each type has say 20 coins. thanks. Let {c1, c2...cn=1} be a set of distinct coin types where ci is... (1 Reply)
Discussion started by: sureshcisco
1 Replies

3. AIX

Analyzing CPU usage

Hi Admins, I need your help to analyze the cpu usage of our main server. I have shared below, CPU usages during busy hours and non busy hours. CPU usage is always full at busy hours. Users always complaints about slowness. This server is a lpar partition and configured as uncapped mode. ... (7 Replies)
Discussion started by: newaix
7 Replies

4. UNIX for Dummies Questions & Answers

analyzing list with street addresses

Hi List, Could someone please point me into the right direction with the following: I have a file containing a list of street addresses. I need to sort all the street addresses with the same number to a new file containing the street name and corresponding number. So: Strawinskylaan... (3 Replies)
Discussion started by: M474746
3 Replies

5. UNIX and Linux Applications

Benchmarking and performance analyzing in OS

Is/Are there an/some application/applications , package/packages for benchmarking or system performance measuring which are there for almost all Linux releases and distributions? (2 Replies)
Discussion started by: nixhead
2 Replies

6. Emergency UNIX and Linux Support

Analyzing Core Dump

We have a binary that generates coredump. So I ran the gdb command to analyze the issue. Pleae note the binary and code are in two different locations and we cannot build the whole binary using debugging symbols. Hence how and what details can I find from below backtarce: gdb binary corefile ... (5 Replies)
Discussion started by: uunniixx
5 Replies

7. AIX

Help required in analyzing errpt in aix 5.3

I have received errpt like this.Any help will be highly appreciated.Recently my application has been migrated to aix 5.3 and working fine in aix 5.2 with out crashes. LABEL: CORE_DUMP IDENTIFIER: C69F5C9B Date/Time: Thu Apr 23 09:41:29 EDT 2009 Sequence Number: 948... (3 Replies)
Discussion started by: kittu1979
3 Replies

8. Shell Programming and Scripting

analyzing tcpdump output

hello, i have a lot of pcap files (tcpdump output) that i want to compare. every tcpdump output has two file, server and client. what i want to do is: 1. take timestamp, source address, destination address, and packet id from each file (server and client) 2. find the packets sent from... (0 Replies)
Discussion started by: slumpia
0 Replies

9. UNIX for Advanced & Expert Users

Analyzing System Core Files?

can some tell me how to do this. I mean, i tried finding this out on my own but when I checked the man pages, i got a truckload of commands available pertaining to this task which in turn got me confused. so my question is, if there is a simple straight forward(not necessarily easy) way to... (2 Replies)
Discussion started by: TRUEST
2 Replies
Login or Register to Ask a Question