09-22-2010
In Sed how can I replace starting from the 7th character to the 15th character.
Hi All,
Was wondering how I can do the following....
I have a String as follows
"ACCTRL000005022RRWDKKEEDKDD...."
This string can be in a file called tail.out or in a Variable called $VAR2
Now I have another variable called $VAR1="000004785" (9 bytes long), I need the content of $VAR1 in the string $VAR2
Example:
VAR1=000004785
|
|
VAR2= "ACCTRL000005022RRWDKKEEDKDD...."
So it should look like...
VAR2= "ACCTRL000004785RRWDKKEEDKDD...."
I know this can be done by sed, but I need to know how to replace from the 7th character till the 15th character.
Any help would be appreaciated.
Thanks,
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
If i have a variable which is a decimal number, i.e 34.05 How can you make decimal point fall on the 15th character on the screen? Or any other that you can specify? Can you do it using sed or awk? (3 Replies)
Discussion started by: Vozx
3 Replies
2. Shell Programming and Scripting
Can someone help me to write a script / command to read in a file, character by character, replace any unknown ASCII characters with space. then write out the file to a new filename/
Thanks! (1 Reply)
Discussion started by: raghav525
1 Replies
3. Shell Programming and Scripting
I have a text file and every line ends in
|^
|^^
|^^^
|^^^^
I need to use sed to make all lines end it
|^
regardless of the amount of carrots.
The code i was using is:
cat FILE | sed 's/\^\^\^/\^/g'
But then they threw that curveball at me. Also is there a way to... (2 Replies)
Discussion started by: insania
2 Replies
4. Shell Programming and Scripting
I have a text file like this
...
B 16 1.340E+05
A 18 3.083E+02
Wu123 1.365E+02
...
I would like to get rid of the 7th character of each line if this is a space character.
Thank you,
Sarah (5 Replies)
Discussion started by: f_o_555
5 Replies
5. Shell Programming and Scripting
cat input.txt
agsbdafgd
ertebrtreter
ahrbrwerg
The last character of a line that does not start with a would be changed to Z.
Final output:
agsbdafgd
ertebrtreteZ
ahrbrwerg
Can anyone post the sed command to do that? (2 Replies)
Discussion started by: cola
2 Replies
6. Shell Programming and Scripting
Hi all,
Greetings,
I have the following scenario, The contents of main file are like :
Unix|||||forum|||||||||||||||is||||||the||best
so||||||be|||||on||||||||||||||||||||||||||||||||||||||||||||it
And i need the output in the following form:
Unix=forum=is=the=best
so=be=on=it
... (3 Replies)
Discussion started by: dipanchandra
3 Replies
7. Shell Programming and Scripting
Hi,
i want find the character '-' in a file from position 284-298, if it occurs i need to replace it with 'O ' for the position in the file. How to do that using SED command.
thanks in advance,
Sara (9 Replies)
Discussion started by: Sara183
9 Replies
8. UNIX for Advanced & Expert Users
hello
i have file with 100k records and each one has certain value that starts at 28th column and certain value that starts at 88th column
e.g. 1st file
<25>1234567 ..... <88> 8573785485
i have aditional file with values which are related to value that starts at 88th column of the... (1 Reply)
Discussion started by: dell1520
1 Replies
9. Shell Programming and Scripting
Hi,
Anyone can help using SED searches a character string for a specified delimiter character, and returns a leading or trailing space/blank.
Text file :
"1"|"ExternalClassDEA519CF5"|"Art1"
"2"|"ExternalClass563EA516C"|"Art3"
"3"|"ExternalClass305ED16B8"|"Art9"
...
...
... (2 Replies)
Discussion started by: fspalero
2 Replies
10. Shell Programming and Scripting
Hi all,
I am looking for to filter out based on 7th character and list the number of occurrence based on the 7th character if p , d , o or m
1. if 7th character is p , Output should be: p_hosts = N
2. if 7th character is d , Output should be: d_hosts = N
3. if 7th character is o , Output... (10 Replies)
Discussion started by: rveri
10 Replies
LEARN ABOUT CENTOS
stringlabels
StringLabels(3) OCaml library StringLabels(3)
NAME
StringLabels - String operations.
Module
Module StringLabels
Documentation
Module StringLabels
: sig end
String operations.
val length : string -> int
Return the length (number of characters) of the given string.
val get : string -> int -> char
String.get s n returns character number n in string s . The first character is character number 0. The last character is character number
String.length s - 1 . You can also write s.[n] instead of String.get s n .
Raise Invalid_argument index out of bounds if n is outside the range 0 to (String.length s - 1) .
val set : string -> int -> char -> unit
String.set s n c modifies string s in place, replacing the character number n by c . You can also write s.[n] <- c instead of String.set s
n c . Raise Invalid_argument index out of bounds if n is outside the range 0 to (String.length s - 1) .
val create : int -> string
String.create n returns a fresh string of length n . The string initially contains arbitrary characters. Raise Invalid_argument if n < 0
or n > Sys.max_string_length .
val make : int -> char -> string
String.make n c returns a fresh string of length n , filled with the character c . Raise Invalid_argument if n < 0 or n >
Sys.max_string_length .
val copy : string -> string
Return a copy of the given string.
val sub : string -> pos:int -> len:int -> string
String.sub s start len returns a fresh string of length len , containing the characters number start to start + len - 1 of string s .
Raise Invalid_argument if start and len do not designate a valid substring of s ; that is, if start < 0 , or len < 0 , or start + len >
StringLabels.length s .
val fill : string -> pos:int -> len:int -> char -> unit
String.fill s start len c modifies string s in place, replacing the characters number start to start + len - 1 by c . Raise Invalid_argu-
ment if start and len do not designate a valid substring of s .
val blit : src:string -> src_pos:int -> dst:string -> dst_pos:int -> len:int -> unit
String.blit src srcoff dst dstoff len copies len characters from string src , starting at character number srcoff , to string dst , start-
ing at character number dstoff . It works correctly even if src and dst are the same string, and the source and destination chunks overlap.
Raise Invalid_argument if srcoff and len do not designate a valid substring of src , or if dstoff and len do not designate a valid sub-
string of dst .
val concat : sep:string -> string list -> string
String.concat sep sl concatenates the list of strings sl , inserting the separator string sep between each.
val iter : f:(char -> unit) -> string -> unit
String.iter f s applies function f in turn to all the characters of s . It is equivalent to f s.[0]; f s.[1]; ...; f s.[String.length s -
1]; () .
val iteri : f:(int -> char -> unit) -> string -> unit
Same as String.iter , but the function is applied to the index of the element as first argument (counting from 0), and the character itself
as second argument.
Since 4.00.0
val map : f:(char -> char) -> string -> string
String.map f s applies function f in turn to all the characters of s and stores the results in a new string that is returned.
Since 4.00.0
val trim : string -> string
Return a copy of the argument, without leading and trailing whitespace. The characters regarded as whitespace are: ' ' , '