I have a problem with the command join. "The default join field is the first, delimited by whitespace" (Cited from join --help). However, there is a field containing sentences in my tab-delimted files. Thus, I want to join the two files using -t\t (I also tried -t "\t" which reported errors under Cygwin, but not under CentOS).
My goal is to extract those lines in File1 which are not present in File2
Let's say File1:
String A
String B
String C
Let's say File2:
String B
String C
Lines are sorted and my output should be:
String A
So I wrote this command for it:
diff File1 File2 | grep '^<' | sed 's/< //g'
which worked fine for my sample files with 10 - 20 lines.
I also tried this command:
grep -Fxv -f
I have file1 and file2
I lookup field3 from file2 in field1 of file1 and if there is a match, output field 2,3,5 from file2.
I now want to add field2 of file1 in the output.
I suspect what I have to do is read the entire line of file1 into a 2 dim array? pls help.
Hi,
Please explain the working process of join command.
File 1
Code:
P B
S A
C A
File2
Code:
C B
P A
S D
But the output of join command is...
join File1.txt File2.txt
Code:
P B A
S A D
But I guess the output should be
Code:
P B A
S A D
C A B
Please correct me,if i am worong or missing some thing.
Thanks
Hi All,
I have two files in the directory
file1.txt
file2.txt
I gave ls -m > output.txt command and I got the output as
file1.txt, file2.txt, output.txt
But my output should be like
file1.txt, file2.txt
Thanks in advance.
Hi Everyone!
I would like ask if there's a better way I can delete multiple lines in a file1 by collecting all criteria from file2.
file1:
a
b
c
d
e
f
file2:
a
e
f
The expected value will be:
b
c
d
The code below seems to work however if is taking much time when dealing with huge records.
I'm quite new to Linux and specially to the shell and all of its commands. My goal is to move some files in every directory to another directory. To be more clear, I have this:
/DIR
- /dir1
- file1
- file2
- ...
- /dir2
- file1
- file2
- ...
- ...
- /dirn
- file1
- file2
- ...
I am just tired of using the join command and not getting the desired result, and it returns some error.
One more thing I've read all queries related to the join command here and in SuperUser also, but couldn't get success.
How can I use join or awk?
file1.csv
autoid|Mycolumn
5|Odhav, Gujarat, 380010
7|Navrangpura, Gujarat, 380009
16|Kalupur, Gujarat, 380002
32|Naroda, Gujarat, 380025
62|Khamas
Have a few hundred files that I have no control over. I need to join them on a common string. There are two files per unit. The file names are:
AAAA_X_file1.txt
AAAA_file2.txt
join -a1 file1 file2 - this works.
My question is, is there a way to use the join command listing the file names only?