Skip to main content

All Questions

Tagged with
1 vote
3 answers
64 views

edit all the values in a specific column based on row numbers range

I have a PDB file (coordinates of atoms in a protein) on a Linux machine: ATOM 1 N GLY A 1 0.535 51.766 5.682 1.00 0.00 ATOM 2 CA GLY A 1 -0.712 50....
Paolo Lorenzini's user avatar
4 votes
5 answers
467 views

Remove the first field (and leading spaces) with a single AWK

Consider this input and output: foo bar baz bar baz How do you achieve with a single AWK? Please explain your approach too. These are a couple tries: $ awk '{ $1 = ""; print(substr($0, 2)) ...
mbigras's user avatar
  • 3,422
1 vote
2 answers
86 views

Filter for arbitrary AND patterns [duplicate]

Consider a command which takes arguments like this: cmd foo bar baz [arbitrary args...]. How do you build a filter of AND patterns based on those arguments? Something like this pipeline of greps: grep ...
mbigras's user avatar
  • 3,422
4 votes
3 answers
220 views

Add columns from variable number of files to base file

I'm dealing with a series of bed files, which look like this: chr1 100 110 0.5 chr1 150 175 0.2 chr1 200 300 1.5 With the columns being chromosome, start, end, score. I have multiple different files ...
Whitehot's user avatar
  • 245
0 votes
2 answers
89 views

BSD sed/awk moving portion of line to line above (switching attribute in HTML file)

My situation is simple : I have an HTML file with several lines containing only the indented <section> block tag, each line followed by an (also indented) <h3 id="YYYY">...</...
sylvansab's user avatar
  • 109
2 votes
3 answers
86 views

Printing a specific section everytime search results are matched

I have a pretty basic text file on a Linux machine that has stuff like Chapters, Dialogues and References. This is what it looks like Chapter: 1 One: Birds and Trees Birds are beautiful and trees ...
learningregularexpressions's user avatar
3 votes
3 answers
410 views

duplicate columns with AWK and separate them by tab

I have a large file with the following format tab-separated: #CHROM POS ID REF ALT QUAL FILTER INFO FORMAT recombination chr1 586001 >63041388>63041391 G ...
Matteo's user avatar
  • 199
0 votes
4 answers
164 views

Aligning space separated words in columns

There is a text file, file.txt. In there is: abc 01245 def-1 32154 ghi-3 55432 jkl 44121 mno-4 23147 pqr 897044 .... How to format this to an output like this: abc 01245 def-1 32154 ghi-3 55432 jkl ...
user447274's user avatar
1 vote
1 answer
90 views

awk won't use literal '\\n' as a delimiter

I have the following file of text that I need to use to give to a Discord webhook: some\nText\nHere The \n separators are literal characters, not actual new lines (the webhook parses them later as new ...
TommyPeanuts's user avatar
-2 votes
3 answers
112 views

Awk to pick up json values

I am trying to get the job status from the below json file.. but while using awk it is returning { "id": 10870, "type": "job", "url": "/api/v2/...
user984993's user avatar
2 votes
7 answers
275 views

merge multiple files using full join by the first column

I have a directory with 200 samples. Each file has two columns. I want to full join these files and make a joined file This is the example of $ head 346_T1_A_deduped.bismark.cov_format 1_10525 95.2 ...
Anna1364's user avatar
  • 1,064
3 votes
3 answers
355 views

Large file manipulation

I have a Garmin Nuvi which uses OpenStreet maps. Garmin do postcodes, but is usually 2-3 years out of date for Scotland. OSM does not do British postcodes, but the Post office does, and it can be ...
user256787's user avatar
3 votes
6 answers
393 views

Print lines between two patterns where first pattern appears more than once before second pattern

I am trying to find a way to use awk to print the lines between two patterns, Virtual and Redirect, but only if the two patterns are consecutive, exclusive of any other strings between them. Example ...
JPaul's user avatar
  • 39
1 vote
3 answers
112 views

sed: To match a newline and spaces

I have a following file: <head> <title>this is a title</title> <style> here goes a style sheet </style> </head> I need to strip the <title> element ...
jsx97's user avatar
  • 1,347
7 votes
6 answers
753 views

Split column into lines using awk

I have a file that contains a long column and I want to split it into lines, each one with 5 values. E.g., Input file: 1 2 3 4 5 6 7 8 9 10 Output file: 1 2 3 4 5 6 7 8 9 10
Djabri Josef's user avatar

15 30 50 per page
1
2 3 4 5
199