|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
|||
|
|||
|
replacement cmd?
I have a file with three Columns (Id, First Name, Last Name) and a file that have one line as follows:
Id, other strings, First Name, Last Name, other strings I want to create a new file that will replace Id, First Name, Last Name of the second file with all corresponding lines of the first file. In that sense the new file will have the same number of lines with the first one. Awk does not work since the strings that exist as default in the second file are quiet long and I got the following error: awk: string too long near line 1 Any idea if there is any other way? thank you |
|
#2
|
|||
|
|||
|
Can you give examples of the file you've got and the result you want to end up with?
|
|
#3
|
|||
|
|||
|
Quote:
Ok, I have a file with 3 columns 1,444666999,999888999000 2,777888999,888333999888 3,222888991,333222111000 etc and I want to produce the following file: 1A444666999BN999888999000end 2A777888999BN888333999888end 3A222888991BN333222111000end etc Column 1 appears before A, column B appears after A and column C appears after BN. This is a pure example. In fact strings A, CB and end are too long and for that I cannot use awk to print them. Best Regards, |
|
#4
|
|||
|
|||
|
This should help:
cat /var/tmp/asb 1,444666999,999888999000 2,777888999,888333999888 3,222888991,333222111000 string1=hello string2=bye string3=end sed "s/\(.*\),\(.*\),\(.*\)/\1${string1}\2${string2}\3${string3}/" /var/tmp/asb 1hello444666999bye999888999000end 2hello777888999bye888333999888end 3hello222888991bye333222111000end |
|
#5
|
|||
|
|||
|
Quote:
ok, thanks. |
|
#6
|
|||
|
|||
|
try this
Hi
just try this sed "s/\(.*\),\(.*\),\(.*\)/\1FIRSTSUBSTITUTION\2SECONDSUBST\3THIRDSUBST/" filename {pls note that the command should be on single line let me know how it works! regards kalpana Quote:
|
![]() |
| Viewing: Dev Shed Forums > Operating Systems > UNIX Help > replacement cmd? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|