Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Inserting n characters to beginning of line if match Post 303007719 by jvoot on Monday 20th of November 2017 04:23:07 PM
Old 11-20-2017
Inserting n characters to beginning of line if match

I would like to insert n number of characters at the beginning of each line that starts with a given character. If possible, I would be most appreciative for a sed or awk solution.

Given the data below, I would like to be able to insert either 125 spaces or 125 "-" at the beginning of every line that begins with "@".

Code:
 
@PS001,001 VWB                 0   2 -1 -1 -1  5 -1   -1 -1  3  2     
@PS001,001 HJ==                0   7 -1 -1 -1 -1 -1   -1  3  1  2
 PS001,001 >CR=                0   2 -1 -1 -1  5 -1   -1 -1  3  2

Thank you so much.

Last edited by jvoot; 11-20-2017 at 06:30 PM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Inserting new line after match of a fixed string

Hi, I have a file which contains many occurances of a string say "hellosunil". I want to insert a newline charcater after all the "hellosunil" strings in the file. trying to use sed, sed -e 's/hellosunil/\\nhellosunil/g' file1 sed help says u cannot substitute a regular expression... (6 Replies)
Discussion started by: sunil_neha
6 Replies

2. Shell Programming and Scripting

inserting characters before each line...

Hi , the fog is fulling my brain after holidays , somebody can help me ? I have a file in input like that : toto tata tutu and trying with awk to insert the compete file string as : /dir1/dir2/toto /dir1/dir2/tata /dir1/dir2/tutu i used to write : awk 'BEGIN {FS="\\"} {print... (4 Replies)
Discussion started by: Nicol
4 Replies

3. UNIX for Dummies Questions & Answers

Inserting control characters at the end of each line

How to add control characters at the end of each line in a file? Can anyone help me with this? Thanks, Shobana (2 Replies)
Discussion started by: Shobana_s
2 Replies

4. UNIX for Dummies Questions & Answers

Compare 2 lists using a full and/or partial match at beginning of line?

hello all, I wonder if anybody might be able to help with this. I have file 1 and file2. Both files may contain thousands of lines that have variable contents. file1 234GH 5234BTW 89er 678tfg 234 234YT tfg456 wert 78gt gh23444 (7 Replies)
Discussion started by: Garrred
7 Replies

5. Shell Programming and Scripting

search pattern and replace x-y characters in nth line after every match

Hi, I am looking for any script which can do the following. have to read a pattern from fileA and copy it to fileB. fileA: ... ... Header ... ... ..p1 ... ... fileB: .... .... Header (3 Replies)
Discussion started by: anilvk
3 Replies

6. UNIX for Dummies Questions & Answers

How to specify beginning-of-line/end-of-line characters inside a regex range

How can I specify special meaning characters like ^ or $ inside a regex range. e.g Suppose I want to search for a string that either starts with '|' character or begins with start-of-line character. I tried the following but it does not work: sed 's/\(\)/<do something here>/g' file1 ... (3 Replies)
Discussion started by: jawsnnn
3 Replies

7. Shell Programming and Scripting

Removing one or more blank characters from beginning of a line

Hi, I was trying to remove the blank from beginning of a line. when I try: sed 's/^ +//' filename it does not work but when I try sed 's/^ *//' filename it works But I think the first command should have also replaced any line with one or more blanks. Kindly help me in understanding... (5 Replies)
Discussion started by: babom
5 Replies

8. UNIX for Dummies Questions & Answers

How to match on phrase at beginning of line and specific columns?

Here is my file: 700 7912345678910 61234567891234567891 700 8012345678910 61234567891234567891 I want to pull all lines that begin with '700' only if columns 11-12 are '79'. My code so far only pulls the '79', not the whole line: grep ^700 file1 | cut -c 11,12 |... (7 Replies)
Discussion started by: Scottie1954
7 Replies

9. Shell Programming and Scripting

[Solved] Inserting a line beginning with regex

I have been trying to insert a line after a regex but I can't do it. Here is the code I am using: cat saved_doc SET type = type1 SET type = STORE = y /vol/san_e1 /vol/san_5 /vol/san_e9 /vol/san_e11 /vol/san_e12 /vol/san_e13 /vol/san_e14 /vol/san_e16 /vol/san_e17 /vol/san_e18... (4 Replies)
Discussion started by: newbie2010
4 Replies

10. UNIX for Beginners Questions & Answers

Removing characters from beginning of multiple files

Hi, I have been searching how to do this but I can't seem to find how to do it. Hopefully someone can help. I have multiplr files, 100's example 12345-zxys.213423.zyz.txt. I want to be able to take all these files and remove the first '12345-' from each of the files. '12345-' these characters... (5 Replies)
Discussion started by: israr75
5 Replies
ORDERS(7)					       BSD Miscellaneous Information Manual						 ORDERS(7)

NAME
orders -- orders of magnitude DESCRIPTION
The following table lists common multiples of bytes. Name Prefix Power of 2 Power of 10 Kilobyte kB 2^10 10^3 Megabyte MB 2^20 10^6 Gigabyte GB 2^30 10^9 Terabyte TB 2^40 10^12 Petabyte PB 2^50 10^15 Exabyte EB 2^60 10^18 Zettabyte ZB 2^70 10^21 Yottabyte YB 2^80 10^24 The following table lists common bit rates as a power of ten. Name Prefix Bit per second Byte per second Bit per second bit/s 1 0.125 Byte per second B/s 8 1 Kilobit per second kbit/s 10^3 125 Kilobyte per second kB/s 8 * 10^3 1000 Megabit per second Mbit/s 10^6 125000 Megabyte per second MB/s 8 * 10^6 1000000 Gigabit per second Gbit/s 10^9 125000000 Gigabyte per second GB/s 8 * 10^9 1000000000 Terabit per second Tbit/s 10^12 125000000000 Terabyte per second TB/s 8 * 10^12 1000000000000 The following table lists common orders of magnitude as a power of ten. Name Order Prefix Symbol Decimal Septillionth 10^-24 yocto y 0.000000000000000000000001 Sextillionth 10^-21 zepto z 0.000000000000000000001 Quintillionth 10^-18 atto a 0.000000000000000001 Quadrillionth 10^-15 femto f 0.000000000000001 Trillionth 10^-12 pico p 0.000000000001 Billionth 10^-9 nano n 0.000000001 Millionth 10^-6 micro mu 0.000001 Thousandth 10^-3 milli m 0.001 Hundredth 10^-2 centi c 0.01 Tenth 10^-1 deci d 0.1 One 10^0 - - 1 Ten 10^1 deca da 10 Hundred 10^2 hecto h 100 Thousand 10^3 kilo k 1000 Million 10^6 mega M 1000000 Billion 10^9 giga G 1000000000 Trillion 10^12 tera T 1000000000000 Quadrillion 10^15 peta P 1000000000000000 Quintillion 10^18 exa E 1000000000000000000 Sextillion 10^21 zetta Z 1000000000000000000000 Septillion 10^24 yotta Y 1000000000000000000000000 SEE ALSO
units(1), strsuftoll(3), number(6) STANDARDS
There have been various attempts to standardize the set of binary prefixes. Organizations such as International Electrotechnical Commission (IEC) have proposed new prefixes such as ``kibi'', ``mebi'', ``gibi'', and ``yobi'', but the adoption has been slow at best. BSD
August 6, 2011 BSD
All times are GMT -4. The time now is 04:02 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy