10-28-2011
It did not work. This command deleted more lines than i was expecting. Can we check by two columns in file1.txt to be sure it deletes the correct lines? It has to be the exact match not the subset.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
I've been searching around here and other places, but can't put this together...
I've got a unique list of words in file 1 (one word on each line).
I need to delete each line in file2 that begins with the word in file1.
I started this way, but want to know how to use file1 words instead... (13 Replies)
Discussion started by: michieka
13 Replies
2. Shell Programming and Scripting
file1:-
aaaa
bbbb
cccc
dddd
eeee
file2:-
1111
2222
3333
4444
I want to insert file2 after pattern bbbb to come up with a finished file of :-
aaaa
bbbb
1111
2222
3333
4444 (5 Replies)
Discussion started by: repudi8or
5 Replies
3. Shell Programming and Scripting
Hello,
I have two files that I need to compare and print out the line from file2 that has the first 6 fields matching the first 6 fields in file1. Complicating this are the following restrictions
1. file1 is only a few thousand lines at most and file2 is greater than 2 million
2. I need to... (7 Replies)
Discussion started by: gillesc_mac
7 Replies
4. Shell Programming and Scripting
hi;
my file2.txt:portname=1;list=10.11;l-
portname=2;list=10.12;l-
portname=3;list=10.13;l-
...
my file1.txt:;"{'sector=%27'}"\&>
so; i want to see:portname=1;list=10.11;l-;"{'sector=%27'}"\&>
portname=2;list=10.12;l-;"{'sector=%27'}"\&>
portname=3;list=10.13;l-;"{'sector=%27'}"\&>... (4 Replies)
Discussion started by: gc_sw
4 Replies
5. UNIX for Dummies Questions & Answers
I have very limited coding skills but I'm wondering if someone could help me with this. There are many threads about matching strings in two files, but I have no idea how to add a column from one file to another based on a matching string.
I'm looking to match column1 in file1 to the number... (3 Replies)
Discussion started by: pathunkathunk
3 Replies
6. Shell Programming and Scripting
Hi guys!
I'm trying to write something to find each line of file1 into file2, if line is found return YES, if not found return NO. The result can be written to a new file.
Can you please help me out?
FILE1 INPUT:
WATER
CAR
SNAKE
(in reality this file has about 600 lines each with a... (2 Replies)
Discussion started by: demmel
2 Replies
7. Shell Programming and Scripting
Good day,
I have a list of regular expressions in file1. For each match in file2, print the containing line and the line after.
file1:
file2:
Output:
I can match a regex and print the line and line after
awk '{lines = $0} /Macrosiphum_rosae/ {print lines ; print lines } '
... (1 Reply)
Discussion started by: pathunkathunk
1 Replies
8. Shell Programming and Scripting
I have two files.
File 1 is a two-column index file, e.g.
comp11084_c0_seq6:130-468(-) comp12746_c0_seq3:140-478(+)
comp11084_c0_seq3:201-539(-) comp12746_c0_seq2:191-529(+)
File 2 is a sequence file with headers named with the same terms that populate file 1. ... (1 Reply)
Discussion started by: pathunkathunk
1 Replies
9. Shell Programming and Scripting
Hi, I wanted to add each row of file2.txt to entire length of file1.txt given the sample data below and save it as new file. Any idea how to efficiently do it. Thank you for any help.
input file
file1.txt file2.txt
140 30 200006 141 32
140 32 200006 142 33
140 35 200006 142... (5 Replies)
Discussion started by: ida1215
5 Replies
10. UNIX for Dummies Questions & Answers
I want to print only the lines in file2 that match file1, in the same order as they appear in file 1
file1
file2
desired output:
I'm getting the lines to match
awk 'FNR==NR {a++}; FNR!=NR && a' file1 file2
but they are in sorted order, which is not what I want:
Can anyone... (4 Replies)
Discussion started by: pathunkathunk
4 Replies
paste(1) General Commands Manual paste(1)
Name
paste - merge file data
Syntax
paste file1 file2...
paste -dlist file1 file2...
paste -s [-dlist] file1 file2...
Description
In the first two forms, concatenates corresponding lines of the given input files file1, file2, etc. It treats each file as a column or
columns of a table and pastes them together horizontally (parallel merging).
In the last form, the command combines subsequent lines of the input file (serial merging).
In all cases, lines are glued together with the tab character, or with characters from an optionally specified list. Output is to the
standard output, so it can be used as the start of a pipe, or as a filter, if - is used in place of a file name.
Options
- Used in place of any file name, to read a line from the standard input. (There is no prompting).
-dlist Replaces characters of all but last file with nontabs characters (default tab). One or more characters immediately following -d
replace the default tab as the line concatenation character. The list is used circularly, i. e. when exhausted, it is reused. In
parallel merging (i. e. no -s option), the lines from the last file are always terminated with a new-line character, not from the
list. The list may contain the special escape sequences:
(new-line), (tab), \ (backslash), and (empty string, not a null
character). Quoting may be necessary, if characters have special meaning to the shell (for example, to get one backslash, use
-d"\\" ).
Without this option, the new-line characters of each but the last file (or last line in case of the -s option) are replaced by a
tab character. This option allows replacing the tab character by one or more alternate characters (see below).
-s Merges subsequent lines rather than one from each input file. Use tab for concatenation, unless a list is specified with -d
option. Regardless of the list, the very last character of the file is forced to be a new-line.
Examples
ls | paste -d" " -
list directory in one column
ls | paste - - - -
list directory in four columns
paste -s -d"
" file
combine pairs of lines into lines
Diagnostics
line too long
Output lines are restricted to 511 characters.
too many files
Except for -s option, no more than 12 input files may be specified.
See Also
cut(1), grep(1), pr(1)
paste(1)