Skip to content
  • View menu
  • View sidebar

bioinfo core

Index & solution of bioInfo utilities

  • Home
  • All entries
  • Blogs
  • Contact
  • About

Categories

  • Between languages (7)
  • Blogs (8)
  • Python (35)
  • R (1)
  • Unix (37)

Tags

bedfile Blogs conda Excel html numpy Pandas Python R slurm Unix
05/04/202010/21/2021 by bioinfocore

Unix regex grep extract substring

  • Unix
  • Unix

Using grep to extract substrings:

grep -oP 'G*_\K(.+)(?=.bw)'

# \K defines the beginning; (?=) for the string end.
# eg. extract bigwig file names
ls -lah folder/* | cut -d' ' -f 10 | grep -E 'bw' | grep -oP 'G*_\K(.+)(?=.bw)'

Source:
https://unix.stackexchange.com/questions/437405/opposite-of-k-to-keep-the-stuff-right

Post navigation

← Previous Post Pandas rename one column or one index
Next Post → Unix remove repeated rows
Copyright 2024 | by bioinfocore