Sponsored Content
Full Discussion: Search and Replace with "sed
Top Forums UNIX for Dummies Questions & Answers Search and Replace with "sed Post 8545 by rwb1959 on Sunday 14th of October 2001 12:11:50 PM
Old 10-14-2001
Well... depending on the "structure" of the
data items in the file, you could simply
use a shell script and "read" each line into
3 distinct variables and simply "echo" the single
variable to a new file. Again, I'm also not
exactly sure if you also wanted to strip the
first variable from the source file but you
could do somthing like...

#!/bin/sh

while read first second third
do
echo $first >> ./new_file_1var
echo $second $third >> ./new_file_2vars
done < ./source_file_3vars

exit 0

Again, this assumes the data in the source file
contains no spaces in the data items themselves
only whitespace separating data items.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Failed to replace string with "sed"

Hi folks, I have the following configuration file: tofu:/tmp # cat bitbandConfig.properties maestroIp=10.10.10.10 maestroPort=2020 adminPlayPath=<Streaming Agent IP>:2021/streamingGateway/GetPlayList ###This part should not be changed### adminPlayVODProtocol=http username=iptv... (7 Replies)
Discussion started by: nir_s
7 Replies

2. Shell Programming and Scripting

replace word with using "sed" not work...

Hi, I have a xml text file with the following data, I would like replace F0</Number> to F</Number> only. i used sed to replace, but it not work!! anyone can help? <Number>11 20 03 22 23 21 91 00 F0</Number> <Number>12 20 03 20 99 21 91 20 F0</Number> <Number>10 21 03 21 78 21 92 27... (28 Replies)
Discussion started by: happyv
28 Replies

3. Shell Programming and Scripting

Sed , Replace a "variable text" inside of a statement

Please Help... I am trying to manipulte the following line Before : <user:Account_Password>002786</user:Account_Password> the password is the "variable", i need to delete / omit the password in the file, (it occurs several thousand times) so the tag line looks like After:... (4 Replies)
Discussion started by: jackn7
4 Replies

4. Shell Programming and Scripting

sed: a "replace unless match" question

Context: I am using sed in a cronjob to change the dates in a separate sql script every week. Each week the dates must be updated to reflect the Monday and Friday of the previous week. I have solved the problem but in solving it I discovered a major weakness in my knowledge of sed. Lines to be... (0 Replies)
Discussion started by: Bubnoff
0 Replies

5. Shell Programming and Scripting

Interesting question - Search and replace the word after sign "="

Hi Guys, Req your help in searching and replacing the word that comes after equals(=) symbol I would like to replace the sting in bold with a string in variable. d=ABCDF8C44C22 # grep -i NIM_MASTERID ${_NIMINFO} export NIM_MASTERID=00CDF8C44C00 I'm looking to replace any word that... (4 Replies)
Discussion started by: ajilesh
4 Replies

6. UNIX for Dummies Questions & Answers

sed for "/7.*" search and replace

Hi , I have this file having thousands of records in it . I want to remove every 9 digit number starting with 7 in it . The few lines from the sample file are "/-GEO-Prizm-Dashes-Covers-Caps-Trim/720000100-200742232-600022761.car"... (8 Replies)
Discussion started by: capri_drm
8 Replies

7. Shell Programming and Scripting

Script to search a string which is in between "" and replace it with another character

Hi, I am trying to search a string from a text file which is in between "" (Double Quotes) (Eg: "Unix"), and replace it with a | where ever it is appearing in the text file and save the file. Please help me. -kkmdv (6 Replies)
Discussion started by: kkmdv
6 Replies

8. Shell Programming and Scripting

Awk to Search and Replace inside the pipe "|"

Hi, Anyone can help me on how to replace the qoutes inside the pipe | in my Text File like belows; "AAAA"|"Test "1-A""|"Test AAAA"|"This is A" "BBBB"|"Test "1-B""|"Test BBBB"|"This is B" "CCCC"|"My Test C"|"Test "CCCC""|"This is C" The output I need like belows; "AAAA"|"Test 1-A"|"Test... (12 Replies)
Discussion started by: fspalero
12 Replies

9. Shell Programming and Scripting

search and replace ""/

I have a csv whose contents look like this abc 1 6 12/13 14/15 i want to output as abc 1 6 12 13 14 15 I am a noob...any help would be appreciated. (4 Replies)
Discussion started by: mumbaiguy07
4 Replies

10. Shell Programming and Scripting

Using sed command to replace "|" with ^ for all *.dat files in a folder not working

I am trying to use the below sed command to replace all "|" to ^, in a folder had 50 dat files. when i tried with 1 file it worked but when i tried with wild card, is not working. sed -i 's/"|"/\^/g' *.dat Is this the proper way to use sed command thank you very much for help. (3 Replies)
Discussion started by: cplusplus1
3 Replies
lreplace(n)						       Tcl Built-In Commands						       lreplace(n)

__________________________________________________________________________________________________________________________________________________

NAME
lreplace - Replace elements in a list with new elements SYNOPSIS
lreplace list first last ?element element ...? _________________________________________________________________ DESCRIPTION
lreplace returns a new list formed by replacing one or more elements of list with the element arguments. first and last specify the first and last index of the range of elements to replace. 0 refers to the first element of the list, and end (or any abbreviation of it) may be used to refer to the last element of the list. If list is empty, then first and last are ignored. If first is less than zero, it is considered to refer to the first element of the list. For non-empty lists, the element indicated by first must exist. If last is less than zero but greater than first, then any specified elements will be prepended to the list. If last is less than first then no elements are deleted; the new elements are simply inserted before first. The element arguments specify zero or more new arguments to be added to the list in place of those that were deleted. Each element argu- ment will become a separate element of the list. If no element arguments are specified, then the elements between first and last are sim- ply deleted. If list is empty, any element arguments are added to the end of the list. SEE ALSO
list(n), lappend(n), lindex(n), linsert(n), llength(n), lsearch(n), lset(n), lrange(n), lsort(n) | KEYWORDS
element, list, replace Tcl 7.4 lreplace(n)
All times are GMT -4. The time now is 07:56 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy