11-22-2011
Removing columns from a text file that do not have any values in second and third columns
I have a text file that has three columns. But at the end of the text file, there are trailing lines that have missing second and third columns:
4 0.04972604 KLHL28
4 0.0497332 CSTB
4 0.04979822 AIF1
4 0.04983331 DECR2
4 0.04990344 KATNB1
4
4
4
4
How can I remove the trailing lines with missing second and third columns, so that my text file looks like the following:
4 0.04972604 KLHL28
4 0.0497332 CSTB
4 0.04979822 AIF1
4 0.04983331 DECR2
4 0.04990344 KATNB1
Thanks!
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
Hi Experts,
I have a file which looks like in this way
1 2233|A.K Shukla |G.M |Sales |12/12/52|6000
2 9876|Jai Sharma |Director |Production |12/03/50|67000
3 5678|Sumit Chakarborty |D.G.M |Marketing |19/04/43|6000
4 2365|Barun... (2 Replies)
Discussion started by: DilipPanda
2 Replies
2. Shell Programming and Scripting
Hi,
I have a sample file as shown below --
id parent name dba
-----------------------------------... (7 Replies)
Discussion started by: sumirmehta
7 Replies
3. UNIX for Dummies Questions & Answers
Hello everybody,
I have a text file containing 10,000 rows and 5000 columns. The values are separated by a tab.
Ex.
file_ex.ped
1 mike 0 0 2 1 A A G G C T A G
1 jack 0 0 2 2 T A G T C A A C
1 Mary 0 0 1 2 A T G C A T G C
...
I would like a out put file
1 mike 0 0 2 1 AA GG CT AG
1... (7 Replies)
Discussion started by: Unilearn
7 Replies
4. UNIX for Dummies Questions & Answers
Hello,
I have a file with 5 columns that looks like this:
A1BG chr19 + 58863335 58866549
A1BG chr19 - 58858171 58864865
A2LD1 chr13 - 101182417 101186056
A2LD1 chr13 - 101182417 101241046
A2M chr12 - 9220303 9268558
A2ML1 ... (5 Replies)
Discussion started by: wolf_blue
5 Replies
5. UNIX for Dummies Questions & Answers
Hi,
I have a tab delimited text file with multiple columns. The second and third columns include numbers that have not been sorted. I want to extract rows where the second column includes a value between -0.01 and 0.01 (including both numbers) and the first third column includes a value between... (1 Reply)
Discussion started by: evelibertine
1 Replies
6. Shell Programming and Scripting
Hi All ,
I have a requirement where I need to remove duplicates from a fixed width file which has multiple key columns .Also , need to capture the duplicate records into another file .
File has 8 columns.
Key columns are col1 and col2.
Col1 has the length of 8 col 2 has the length of 3.
... (5 Replies)
Discussion started by: saj
5 Replies
7. Shell Programming and Scripting
Hello
I have a file as below
chr1 start ref alt code1 code2
chr1 18884 C CAAAA 2 0
chr1 135419 TATACA T 2 0
chr1 332045 T TTG 0 2
chr1 453838 T TAC 2 0
chr1 567652 T TG 1 0
chr1 602541 ... (2 Replies)
Discussion started by: plumb_r
2 Replies
8. Shell Programming and Scripting
Hello,
I want to concatenate 2-columns by 2-columns separated by colon. How can I do so? For example, I have a text file containing 6 columns separated by tab. I want to concatenate column 1 and 2; column 3 and 4; column 5 and 6, respectively, and put a colon in between.
input file:
1 0 0 1... (10 Replies)
Discussion started by: huiyee1
10 Replies
9. Shell Programming and Scripting
Hi guys,Got a bit of a bind I'm in. I'm looking to remove duplicates from a pipe delimited file, but do so based on 2 columns. Sounds easy enough, but here's the kicker...
Column #1 is a simple ID, which is used to identify the duplicate.
Once dups are identified, I need to only keep the one... (2 Replies)
Discussion started by: kevinprood
2 Replies
10. UNIX for Beginners Questions & Answers
Columns 4 and 5 are X and Y coordinates, column 6 is the elevation
I would like to add 2 new columns at the end of the file with values
the distance between first(X)(Y) and last location (X)(Y), based in 2 rows
the difference in elevation = ($6-prev6)
How to calculate the requested values... (6 Replies)
Discussion started by: jiam912
6 Replies
SDIFF(1) User Commands SDIFF(1)
NAME
sdiff - side-by-side merge of file differences
SYNOPSIS
sdiff [OPTION]... FILE1 FILE2
DESCRIPTION
Side-by-side merge of differences between FILE1 and FILE2.
Mandatory arguments to long options are mandatory for short options too.
-o, --output=FILE
operate interactively, sending output to FILE
-i, --ignore-case
consider upper- and lower-case to be the same
-E, --ignore-tab-expansion
ignore changes due to tab expansion
-Z, --ignore-trailing-space
ignore white space at line end
-b, --ignore-space-change
ignore changes in the amount of white space
-W, --ignore-all-space
ignore all white space
-B, --ignore-blank-lines
ignore changes whose lines are all blank
-I, --ignore-matching-lines=RE
ignore changes all whose lines match RE
--strip-trailing-cr
strip trailing carriage return on input
-a, --text
treat all files as text
-w, --width=NUM
output at most NUM (default 130) print columns
-l, --left-column
output only the left column of common lines
-s, --suppress-common-lines
do not output common lines
-t, --expand-tabs
expand tabs to spaces in output
--tabsize=NUM
tab stops at every NUM (default 8) print columns
-d, --minimal
try hard to find a smaller set of changes
-H, --speed-large-files
assume large files, many scattered small changes
--diff-program=PROGRAM
use PROGRAM to compare files
--help display this help and exit
-v, --version
output version information and exit
If a FILE is '-', read standard input. Exit status is 0 if inputs are the same, 1 if different, 2 if trouble.
AUTHOR
Written by Thomas Lord.
REPORTING BUGS
Report bugs to: bug-diffutils@gnu.org
GNU diffutils home page: <http://www.gnu.org/software/diffutils/>
General help using GNU software: <http://www.gnu.org/gethelp/>
COPYRIGHT
Copyright (C) 2017 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.
SEE ALSO
cmp(1), diff(1), diff3(1)
The full documentation for sdiff is maintained as a Texinfo manual. If the info and sdiff programs are properly installed at your site,
the command
info sdiff
should give you access to the complete manual.
diffutils 3.6 May 2017 SDIFF(1)