Skip to main content

All Questions

-2 votes
2 answers
56 views

Renaming object or element in perticular range in a column of text file

To expand on my previous question, I have another pattern of a file, I am trying to change the name of first column ranging from seq1 to seq20 (seq1-seq20) as seq1 similarly ranging from seq21 to ...
umar's user avatar
  • 117
0 votes
1 answer
356 views

awk prints if and else case

I wrote the following command: lsblk -nl /dev/sdd -o MOUNTPOINT | awk '{if (NR!=1 && $1) { print 1; } else { print 0; }}' It is supposed to check if any of the paritions of the given device, ...
Kyu96's user avatar
  • 183
1 vote
1 answer
301 views

Map field of first file based on patten matching in second file

I have two tab-delimited files where I need to match text in the first column of file 1 to any position in lines of file 2. Upon a match I then want to print what's in the second column of the ...
cjwwfd's user avatar
  • 21
0 votes
3 answers
3k views

Command to extract header of multiple files present in a directory [closed]

For example : there are 50 files present in a Unix directory ,I want to extract header of all the files and write it to a CSV file . CSV file will contain 2 columns 1st column - file name and 2nd ...
Learner's user avatar
  • 19
0 votes
1 answer
344 views

Locating a process ID by CPU usage (Ubuntu) using AWK

I have a command that I run to try and list PID's and their CPU usage. I am using ps -ef. Is there a (better) way to do this using top? Also, I had a question about my awk statement. My variable $...
Michael's user avatar
  • 33
0 votes
2 answers
1k views

SED or AWK to remove everything before the first dash and after the last

I have a private key file with some extra nonsense in there, and want just the text of the key. so: nonsense -----Begin Key----- keep this1 keep this2 keep this3 -----End Key----- nonsense should ...
J. Tate's user avatar
  • 113
0 votes
2 answers
140 views

Extract and rearrange from file

I have file which I want to extract and rearrange certain data , Old file contains a raw data this file is Input reference:cve,2017-8962 sid:45885 reference:cve,2016-10033 reference:cve,2016-10034 ...
chandu's user avatar
  • 191
1 vote
2 answers
451 views

How to match a column from File1 to get its corresponding fasta sequences in File 2?

May I kindly ask how to match all values of the first column in File with the line text in File 2 so I can copy the fasta sequences of all Object ID in File 1? File 1.csv file Object_ID, Length, ...
beth's user avatar
  • 11
9 votes
4 answers
52k views

script / command to get IPs from list of hostnames and combine into a single file

This is beyond my current skills it seems as I've been trying for a while and not making much headway. I've been asked to get a list of hosts and IPs for security to run a scan against those servers. ...
Ivan Windon's user avatar
3 votes
1 answer
8k views

How to use awk command to calculate the date difference between two columns in the same file?

I have a multi columns csv file, comma separated which has two columns with different date (mm/dd/yyyy). I am going to identify the difference between these two date. following is the example: echo ...
Daniel's user avatar
  • 347
0 votes
3 answers
683 views

Formatting output from awk command in script

If I run this command: awk -F'[="]+' '/^(NAME|VERSION)=/{printf("%-17s: %s\n",$1,$2)}' /etc/os-release from a terminal, I can retrieve this: NAME : Debian GNU/Linux VERSION : 8 ...
marshki's user avatar
  • 627
1 vote
1 answer
235 views

How to use awk to correct and unify a corrupted file with multiple columns and lines?

I have a CSV formatted multi lines file with 5 columns (fields). I need to unify and corrected the corrupted first column which has lots of different formats of the code I need to unify. The complete ...
Daniel's user avatar
  • 347
2 votes
1 answer
67 views

How I can find line(s) which the third columns is not digit/date?

I am trying to use awk command to find line(s) which the third columns is not digit/date? Suppose there is a file comma "," field separated, has three columns and as code "," measure "," dd/mm/yyyy, ...
Daniel's user avatar
  • 347
2 votes
6 answers
2k views

awk / sed / etc. concatenating colums in one file

I wonder what is a simpler way to do this: awk 'NR > 1 {print $1"\t"$2"\t"$3"\t"$4"\t"$5"\t"$6"\t"$7"\t"$8"\t"$9$10$11$12$13$14$15$16}' file.in > file.out which is simply speaking " ...
xi100f's user avatar
  • 143
-2 votes
2 answers
1k views

standard deviation using awk [closed]

I am using below command to get standard deviation of file A names 1 2 3 avg 23.3107 20.0372 21.7236 21.6905 awk '{x[NR]=$0 ;} END{a=$4; for (i in x){ss += (x[i]-...
star's user avatar
  • 745

15 30 50 per page