Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Favorites infavorites:mine
infavorites:1234
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with Search options user 85039

Manipulation or examining of text by programs, scripts, etc.

2
votes
What you have there is file2 repeating once all the lines in the file2 have been read. Here's an awk/sed solution that takes number of lines in file2 as variable, and prints lines in file2 according t …
answered Aug 11 '15 by Sergiy Kolodyazhnyy
1
vote
Here's a perl version using negative lookahead (?!ORGANISM) to figure out if we need to perform substitution. -p flags allows automatic printing $ perl -pe 's/[[:blank:]]//g if /^(?!ORGANISM).*/' inp …
answered Jun 1 '17 by Sergiy Kolodyazhnyy
5
votes
Python and numpy The input data that we're looking at can be treated as a matrix or 2-dimensional array. Now, if we approach the problem from this point of view, there's several computational tools t …
answered Jul 5 '17 by Sergiy Kolodyazhnyy
1
vote
Since you mentioned that you're familiar with Python, here's a python script that can do the job: #!/usr/bin/env python from __future__ import print_function import os,re,sys def read_file(filepath) …
answered Jan 13 '17 by Sergiy Kolodyazhnyy
4
votes
AWK is a quite decent tool for such purpose as well. Here's sample run of code: $ awk 'NR == 1 {print} NR != 1 && $0!~/ID Data1 Data2/' rmLines.txt | head -n 10 ID …
answered Jan 27 '16 by Sergiy Kolodyazhnyy
1
vote
You can use awk on this. awk '{for(i=1;i<=NF;i++) printf "%s\n",$i}' input.txt
answered Jul 13 '18 by Sergiy Kolodyazhnyy
1
vote
Shell approach: while IFS= read -r line || [ -n "$line" ]; do [ "${#line}" -gt 79 ] && printf "%s\n" "$line" done < input.txt Python approach: python -c 'import sys;f=open(sys.argv[1]);print …
answered Dec 3 '17 by Sergiy Kolodyazhnyy
0
votes
One possible approach is via awk and using = as field separator: $ awk -F'=' 'BEGIN{OFS="=";};/^prefix/{$2=""; print; noprint=1};/^suffix/{noprint=0;print};noprint{next;};' input.txt prefix = suffix …
answered Jun 10 by Sergiy Kolodyazhnyy
1
vote
Your question states that column 3 contains names of genes. I assume your actual input is as follows: column1 column2 Rv0729,Rv0993,Rv1408 column1 column2 Rv0162c,Rv0761c,Rv1862,Rv3086 column1 co …
answered Mar 8 '17 by Sergiy Kolodyazhnyy
5
votes
VIM solutions There's two solutions: one is via automating Ctrla keypress over a selection, second is via executing a pattern replacement with submatch(0)+1 over the selection. First the key automati …
answered Aug 28 '16 by Sergiy Kolodyazhnyy
0
votes
Slightly crude, but working GNU awk: $ awk -v sq="'" '/KEYWORD/{if ($0~sq){ gsub(sq,"\"")} else if ($0~"\"") gsub(/\"/,sq)};1' input.txt KEYWORD_1 table name column = 'string' A …
answered Jan 14 '17 by Sergiy Kolodyazhnyy
0
votes
As has been mentioned , you can't achieve what you want with tr due to the nature of tr. But there are many other alternatives. For instance, Python 2. As one-liner we could do this: python -c "impo …
answered Jan 4 '17 by Sergiy Kolodyazhnyy
1
vote
Here's an awk approach, which relies on splitting even and odd lines into appropriate arrays. $ awk 'NR%2 !=0 {split($0,col1)}; NR%2 == 0 {split($0,col2); for (i=1;i<=length(col1);i++) print col1[i], …
answered Jan 17 '17 by Sergiy Kolodyazhnyy
8
votes
Goro's answer will work, but it should be noted that command substitution removes trailing newlines as specified by POSIX standard. Thus it may not be desirable where you want to actually iterate ove …
answered Sep 8 '18 by Sergiy Kolodyazhnyy
0
votes
In awk this can be done via adding lines of file into array, and iterating through array via nested loop within END statement: awk '{a[i++]=$0} END{ for(c=1;c<=35;c++) for(j=0;j<=i;j++) print a[j]}' …
answered Dec 23 '18 by Sergiy Kolodyazhnyy

15 30 50 per page