Search Results

Search: Posts Made By: evelibertine
1,216
Posted By evelibertine
Writing a script to take the average of two columns every 3 rows
I have a dataset with 120 columns. I would like to write a script, that takes the average of every two columns, starting from columns 2 and 3, and moving consecutively in frames of 3 columns, all the...
4,429
Posted By evelibertine
I tried grepping the lines containing NAs and...
I tried grepping the lines containing NAs and replacing them with the new values using:

grep "NA" input | awk '{print $1,$1,$4,$3,$4,$5,$6;} | sed 's/ /:/2' > output

Then I would grep the...
4,429
Posted By evelibertine
Replacing values in a column if they equal a certain value
Hi,

I have a tab delimited text file where some lines have the string "NA" in the second column. For these lines, I want to replace NA with the value in the first column, the symbol underscore...
1,306
Posted By evelibertine
This does not seem to fix the issue.
This does not seem to fix the issue.
1,306
Posted By evelibertine
For loop in bash shell
Hi,

I am using a for loop to manipulate files data_1.txt through data_100.txt. The for-loop is set up like this:

for i in {1..100}; do cut -f1 data_$i.txt > output$i.txt

I get the following...
1,835
Posted By evelibertine
Using awk in a for loop
Hi,

I have a for loop using awk where I add a column to each file data1.txt through data10.txt where the value in the new column equals 1 through 10:

for i in {1..10}; do awk '$3="$i"'...
15,747
Posted By evelibertine
Using sed in a for loop
Hi,

I have a file called 1.txt, I want to create 2.txt through 100.txt using a for loop. In each instance of the loop, I want to change all "1"'s in the text file to "2"s and so on...

I tried...
1,056
Posted By evelibertine
Extract string between paranthesis
Hi,

I have a file of fasta headers that looks like the following:

>gi|28476830|ref|NR_001281.1| Homo sapiens protocadherin beta 18 pseudogene (PCDHB18), non-coding RNA...
1,714
Posted By evelibertine
I've tried this: awk '!A[$1]++' But if...
I've tried this:
awk '!A[$1]++'

But if there are lines with repeating values in the first column, it still keeps the first line.
1,714
Posted By evelibertine
Deleting rows where the value in a specific column match
Hi,

I have a tab delimited text file where I want to delete all rows that have the same string for column 1. How do I go about doing that? Thanks!

Example Input:
aa 1
aa 2
aa 3
bb 4
bc 5...
1,309
Posted By evelibertine
I've tried : awk '$1!=$2' file1 | awk...
I've tried :

awk '$1!=$2' file1 | awk '{print $1,$2,$3,$4*2}' > file2
awk '$1==$2' file2 | awk '{print $1,$2,$3,$4*2 + 1}' > file 3

It works but I was wondering if there is a way to convert...
1,309
Posted By evelibertine
Mathematical manipulation of a text file
I have a tab delimited file with 4 columns. If the value in the first column, equals the value in the second column, I'd like to have the 4th column multiplied by 2 then add 1. If the value in the...
1,506
Posted By evelibertine
Printing out lines that have the same value in the first column but different value in the second
Hi,

I have a text file that looks like the following:

ILMN_1343291 6 74341083 74341772
ILMN_1343291 6 74341195 74341099
ILMN_1343295 12 6387581 6387650...
7,115
Posted By evelibertine
Extracting rows from a text file if the value of a column falls between a certain range
Hi,

I have a file that looks like the following:

10 100080417 rs7915867 ILMN_1343295 12 6243093 7747537
10 100190264 rs2296431 ILMN_1343295 12 ...
4,181
Posted By evelibertine
I found this one-liner and it seems to do the...
I found this one-liner and it seems to do the trick:

awk '{for (i=1; i<=NF; i++) a[i]=a[i](NR!=1?FS:"")$i} END {for (i=1; i in a; i++) print a[i]}'

Thanks!
4,181
Posted By evelibertine
I'm sorry the question was vague. By transpose I...
I'm sorry the question was vague. By transpose I mean flipping the rows into columns and the columns into rows. The file basically has 2,000,000 columns and 100 rows that all have digits ranging from...
4,181
Posted By evelibertine
Transposing a huge space delimited file
Hi,

How do I transpose a huge space delimited file with more than 2 million columns and about 100 rows? Thanks!
3,169
Posted By evelibertine
Changing only the first space to a tab in a space delimited text file
Hi,

I have a space delimited text file but I only want to change the first space to a tab and keep the rest of the spaces intact. How do I go about doing that? Thanks!
845
Posted By evelibertine
Using grep but printing a line more than once
Hi,

I am using the grep function to grep some lines from a text file. However, a line is grepped only once even if it matches the strings in the first file more than once. How can i change the...
1,532
Posted By evelibertine
Filling in the empty columns with rows above them
Hi,

I have a text file where some of the values in columns are missing:

Input:


QhFudW3dKSYL2NTQUA 1 11133999-11134048
uhIp9KxB6USIy16CEY 1 11126760-11126774
11126775-11126805...
1,590
Posted By evelibertine
Printing all the values in the middle of two columns
Hi,

I have a tab delimited text file with three columns:

Input:

1 25734 25737
1 32719 32724
1 59339 59342
1 59512 59513
1 621740 621745

For each row of the...
1,118
Posted By evelibertine
Excluding a specific column from sed replacement
Hi,

I would like to replace all 0's to 1's throughout my text file. However I do not want column 3 altered. How do I go about doing that? Thanks!
1,641
Posted By evelibertine
Add a column of 0's to a text file
Hi,

I have a text file with many column (1,000,000+). I want to add a column of 0's as the third column. I tried:

awk '{$3=0}1' input file > output file

But it simply replaces the third...
20,410
Posted By evelibertine
Adding a column to a text file with row numbers
Hi,

I would like to add a new column containing the row numbers to a text file. How do I go about doing that? Thanks!

Example input:
A X
B Y
C D

Output:
A X 1
B Y 2
C D 3
10,091
Posted By evelibertine
Changing the values of a column using awk and gsub
Hi,

I am using the following code to change NA to X in only the 5th column of my text file:

awk '{gsub("NA","x",$5)}1' in.file > out.file

How can I modify this code if I want to change NA to...
Showing results 1 to 25 of 193

 
All times are GMT -4. The time now is 05:30 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy