Skip to main content

All Questions

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. ...
-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 ...
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, ...
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 ...
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 ...
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 $...
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 ...
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 ...
3 votes
3 answers
4k views

How to build a long command string?

I've a sequence of commands to be used along with lot of pipings, something like this: awk '{ if ($8 ~ "isad") {print $2, $5, "SE"} else {print $2, $5, "ANT"} }' "/var/log/apache2/other_vhosts_access....
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 ...
14 votes
6 answers
76k views

Awk - output the second line of a number of .dat files to one file

I have multiple files something like: (in reality i have 80) file1.dat 2 5 6 9 7 1 file2.dat 3 7 8 4 1 3 I want to end up with a file containing all of the second lines. i.e. output.dat 6 9 ...
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, ...
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, ...
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 ...
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 ...

15 30 50 per page