Linux Command - split single line into multiple lines
My content of my input file - gene.data look like this:
tang 123 gene gene 3000 1000 4000
where
the 1st column is the name of the gene
the 2nd column is the id of the gene
the 3rd and 4th column are the type of sequence
the 5h column is the size of the gene in base pair.
the 6th column is the starting point of the gene location;
the 7th column is the end point of the gene location.
I would like to divide this line into multiple lines of 600 base pairs each until/before the ending point.
i want the result like this:
tang 123 gene gene 600 1000 1600
tang 123 gene gene 600 1600 2200
tang 123 gene gene 600 2200 2800
tang 123 gene gene 600 2200 2800
tang 123 gene gene 600 2800 3400
tang 123 gene gene 600 3400 4000
what should I do in order to come out these result? can I just write a command line or need to write a script?
Comments
-
you can probably do something like this:
FILE=gene.data ; SPLIT=600 ; START=$(cat $FILE | awk '{print $6}') ; END=$(cat $FILE | awk '{print $7}') ; STATIC=$(cat $FILE | awk '{print $1" " $2" " $3" " $4}') ; while [ $START -lt $END ] ; do echo "$STATIC" $SPLIT "$START $(($START+$SPLIT))" ; START=$(($START+$SPLIT)) ; done1
Categories
- All Categories
- 178 LFX Mentorship
- 178 LFX Mentorship: Linux Kernel
- 774 Linux Foundation IT Professional Programs
- 383 Cloud Engineer IT Professional Program
- 175 Advanced Cloud Engineer IT Professional Program
- 75 DevOps IT Professional Program - Discontinued
- 7 DevOps & GitOps IT Professional Program
- 103 Cloud Native Developer IT Professional Program
- 7.6K Training Courses & Learning Paths
- 11 AI & ML Training
- 1 Blockchain & Decentralized Identity Training
- 32 Cloud & Containers Training
- 3 Cybersecurity Training
- 2 DevOps & Site-Reliability Training
- 1 Linux Kernel Development Training
- 2 Networking Training
- 2 Open Source Best Practice Training
- 5 System Administration Training
- 1 System Engineering Training
- 4 Web & Application Development Training
- 798 Hardware
- 202 Drivers
- 68 I/O Devices
- 37 Monitors
- 96 Multimedia
- 173 Networking
- 91 Printers & Scanners
- 92 Storage
- 772 Linux Distributions
- 81 Debian
- 68 Fedora
- 24 Linux Mint
- 13 Mageia
- 24 openSUSE
- 151 Red Hat Enterprise
- 31 Slackware
- 13 SUSE Enterprise
- 356 Ubuntu
- 469 Linux System Administration
- 31 Cloud Computing
- 73 Command Line/Scripting
- Github systems admin projects
- 101 Linux Security
- 79 Network Management
- 101 System Management
- 46 Web Management
- 160 Mobile Computing
- 29 Android
- 116 Development
- 1.2K New to Linux
- 1K Getting Started with Linux
- 405 Off Topic
- 127 Introductions
- 34 Study Material
- 1K Programming and Development
- 310 Kernel Development
- 718 Software Development
- 1K Software
- 418 Applications
- 182 Command Line
- 5 Compiling/Installing
- 71 Games
- 320 Installation
- Archived
- 183 Small Talk
- 2 LFD140 Class Forum
- 1.4K LFS258 Class Forum
Upcoming Training
-
August 20, 2018
Kubernetes Administration (LFS458)
-
August 20, 2018
Linux System Administration (LFS301)
-
August 27, 2018
Open Source Virtualization (LFS462)
-
August 27, 2018
Linux Kernel Debugging and Security (LFD440)