Comparing rows


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Comparing rows
# 1  
Old 05-20-2014
Comparing rows

Hi,

I have txt file below

Code:
02.05.2014,10.05.2014,dfs,srtytr,tyhty
05.10.2014,15.10.2014,456ef,t6y5fgtd,xg45t
21.11.2014,28.11.2014,sefser,dfw344,zsdfrw
22.12.2014,30.12.2014,fwe,aerw4,zwq4q

my script will ask two input,

Code:
enter start date
05.10.2014
 
enter end date
15.10.2014

If the enter date is present in the txt file then it should process, else throw an error.

The code should compare row by row for two input field
# 2  
Old 05-20-2014
Quote:
If the enter date is present in the txt file then it should process, else throw an error.
What date entered, the start or the end, or between?

Quote:
The code should compare row by row for two input field
What files would it compare and what two input fields would that be?
# 3  
Old 05-20-2014
The star date and end date of the input should match in txt file

In my previus post I enter the sample input date, it is matching the second row from input txt file

Also I hightligted in blue

Code:
enter start date
05.10.2014
 
enter end date
15.10.2014
 
02.05.2014,10.05.2014,dfs,srtytr,tyhty
05.10.2014,15.10.2014,456ef,t6y5fgtd,xg45t
21.11.2014,28.11.2014,sefser,dfw344,zsdfrw
22.12.2014,30.12.2014,fwe,aerw4,zwq4q

# 4  
Old 05-20-2014
sd and ed could be external variables

Code:
awk -v sd="05.10.2014" -v ed="15.10.2014" '$1==sd && $2==ed {print}' FS=, file.txt

 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Comparing two files and writing mismatched rows along with mismatched columns. Pointing out the mism

I got a requirement where I need to compare two files wrt to each columns and write the corresponding difference in another file along with some identification showing mismatched columns. Pointing out the mismatched columns is my main problem statement. For example we have files like: File 1 ... (8 Replies)
Discussion started by: piyush pankaj
8 Replies

2. Shell Programming and Scripting

Moving or copying first rows and last rows into another file

Hi I would like to move the first 1000 rows of my file into an output file and then move the last 1000 rows into another output file. Any help would be great Thanks (6 Replies)
Discussion started by: kylle345
6 Replies

3. UNIX for Dummies Questions & Answers

merging rows into new file based on rows and first column

I have 2 files, file01= 7 columns, row unknown (but few) file02= 7 columns, row unknown (but many) now I want to create an output with the first field that is shared in both of them and then subtract the results from the rest of the fields and print there e.g. file 01 James|0|50|25|10|50|30... (1 Reply)
Discussion started by: A-V
1 Replies

4. Shell Programming and Scripting

Comparing rows and columns

Hi, i've a .csv file with the data as below: - file1.h, 2.0 file2.c, 3.1 file1.h, 2.5 file3.c, 3.3.3 file1.h, 1.2.3 I want to remove the duplicate file names considering only the one with the highest version number.. output should be file1.h, 2.5 file2.c, 3.1 file3.c,... (3 Replies)
Discussion started by: pravsripad
3 Replies

5. Shell Programming and Scripting

Split single rows to multiple rows ..

Hi pls help me out to short out this problem rm PAB113_011.out rm: PAB113_011.out: override protection 644 (yes/no)? n If i give y it remove the file. But i added the rm command as a part of ksh file and i tried to remove the file. Its not removing and the the file prompting as... (7 Replies)
Discussion started by: sri_aue
7 Replies

6. Shell Programming and Scripting

Comparing rows in same file and writing the result in new file

Help needed... Can you tell me how to compare the last two couple entries in a file and print their result in new file..:confused: I have one file Check1.txt \abc1 12345 \abc2 12327 \abc1 12345 \abc2 12330 I want to compare the entries in Check1 and write to... (1 Reply)
Discussion started by: kichu
1 Replies

7. Shell Programming and Scripting

Remove 1st two rows and last 2 rows

Hi All, I need to remove 1st 2 line from head and last 2 line from last. I thought it would be possible by using the Head and tail command. But after i am using it is not possible by it. Example:Input file 1 2 3 4 5 Example: Output file 3 But my head and tail command are not... (12 Replies)
Discussion started by: kam786sim
12 Replies

8. Shell Programming and Scripting

Deleting specific rows in large files having rows greater than 100000

Hi Guys, I need help in modifying a large text file containing more than 1-2 lakh rows of data using unix commands. I am quite new to the unix language the text file contains data in a pipe delimited format sdfsdfs sdfsdfsd START_ROW sdfsd|sdfsdfsd|sdfsdfasdf|sdfsadf|sdfasdf... (9 Replies)
Discussion started by: manish2009
9 Replies

9. UNIX for Dummies Questions & Answers

Converting rows into multiple-rows

Hi every one; I have a file with 22 rows and 13 columns which includes floating numbers. I want to parse the file so that every five columns in the row would be a new record (row). For example, the first line in the old file should be converted into three lines with first two lines contain 5... (6 Replies)
Discussion started by: PHL
6 Replies

10. Shell Programming and Scripting

Comparing rows in two tables and sending the differnce to mail

Hi, I have a table ,containg 2 coloumns and many rows,which is updated everyday.The no.of rows in the table changes everyday. i have to write the difference between yesterdays tabtle and todays table to a new file.The row that is new in the todays table need not to be shown.only the change... (2 Replies)
Discussion started by: bab123
2 Replies
Login or Register to Ask a Question