Skip to main content

All Questions

Tagged with
0 votes
3 answers
282 views

awk/sed in loop to replace numbers (with result of computation)

I am relatively new to awk and sed.  I have a file with more than 30000 rows/lines; e.g., Direct configuration= 5 0.86331344 0.14835363 0.01770155 0.83813858 0.74789354 0.31772038 0.89805721 0....
Sudip Kumar Mondal's user avatar
1 vote
3 answers
137 views

Fetch data from a large file based on time and date recursively

Fetch data based on date(column 1) and time (column 2). Each date has time in column 2. Based on each date in column1 two files are to be generated which will have all the fields based on time 6:00 to ...
Gavin's user avatar
  • 91
1 vote
4 answers
143 views

Remove duplicates by adding numerical suffix

How do I append a numerical suffix to lines to remove duplicates? Pseudo code: if currLine.startsWith("tag:") x = numFutureLinesMatching(currLine) if (x > 0) currLine = currLine + ...
Steven's user avatar
  • 758
-1 votes
1 answer
90 views

Complicated DIFF method

I'm trying to do a compare between a config from an old box and a new box to verify Availability and State haven't changed. I have a file that is generated with about a thousand nodes but every node ...
MyWiseGuys's user avatar
0 votes
3 answers
482 views

How do I use grep, awk, or sed to get a substring of a line up until a string literal?

I am trying to process a text file and omit a certain string literal if it occurs at the end of the line. E.g.: Source: ABC 123 DEF, characters I don't want GHI, these characters are ok Desired ...
Evan Harmon's user avatar
0 votes
4 answers
88 views

Find two lines with unknown number of lines between them

I have a text file with output like this: file_0108.json 2023-02-22T01:15:05.531+0000 connected to: mongodb://[**REDACTED**]@localhost 2023-02-22T01:15:08.531+0000 [######..................] db....
Sebastian's user avatar
0 votes
2 answers
169 views

awk - Processing a file without Header into a csv with the format header,record1,record2

I have a data file in the following format abcd: x:123 y:2345 pqrs: x:456 y:720 mnop: x:234 y:4567 : : How can I translate this to a CSV of the format in awk: abcd,123,2345,<userstring1>,&...
Vikas's user avatar
  • 1
5 votes
5 answers
782 views

How can I replace multiple substrings from multiple lines in a file matching a pattern from a different file?

I have a file that contains multiple IP addresses and hostnames, and another file that contains some folders with many IP addresses per line. ip_hostname.txt host1 10.1.1.1 host2 10.2.2.2 host3 10.3.3....
Outsider's user avatar
-1 votes
1 answer
2k views

Bulk replace multiple variables in multiple files at once

Example: I have 40 different variables like $VAR in 100 .txt files which are located in /home/user/EXAMPLE/. How do I replace all variables in the 100 files? To tell the system what the variables are ...
xorghelpneed's user avatar
0 votes
8 answers
1k views

Rewriting log parsing script in Perl or Python (get rid of awk)

I need accomplish a task of filtering activity of bots in the log file. Solution should only show records meeting following criteria user logged in, user changed password, user logged off within ...
Twissell's user avatar
  • 141
1 vote
2 answers
682 views

Replace a column in file with look up table from another file

I have a tab delimited file with a column that has multiple values separated by comma where i wanted to replace values from a look up table Lookup_file: ID Name g_00001 g_00001 g_00002 cytA ...
Empyrean rocks's user avatar
2 votes
3 answers
463 views

Convert mm to hh:mm

I am using awk to get all of the 4th comma-delimited fields, which is a duration in minutes. The required output is in the format of hh:mm, so I need to convert that from minutes. "jone",&...
SRash's user avatar
  • 111
-1 votes
3 answers
93 views

Changing the place operator in a csv file

I've been editing a CSV file so I can import it into postgres. At this point I want to change the operator from column 5 to the left side of the column when the value is negative"-". When it ...
matheus soares's user avatar
0 votes
0 answers
88 views

Keep every process in 1 execution block in CSV handling

I asked some questions about how to handle a csv file and this result was numerous processes. Every month I get several TXT files in a Google Drive directory. I need to process, unite and load this ...
matheus soares's user avatar
1 vote
4 answers
343 views

Replace contents of first column which have cyclic structure

I have a file in which the first column is to be changed, for example, I have the following file (In the original file I have multiple columns but truncating the following to 2 columns, it may have ...
Akash Tadwai's user avatar

15 30 50 per page
1
2 3 4 5 6