Note that there are some explanatory texts on larger screens.

plurals
  1. POBash - replace string inside all files in directory
    primarykey
    data
    text
    <p>I have 31 .ctl files in a directory, they looks like this:</p> <pre><code>load data CHARACTERSET AL32UTF8 infile '../dane/kontakty_Biura_wyborcze.csv' "str '\n'" append into table ODI_PUW_OSOBY2 fields terminated by ';' OPTIONALLY ENCLOSED BY '"' AND '"' trailing nullcols ( LP CHAR(4000), WOJEWODZTWO CHAR(4000), POWIAT CHAR(4000), GMINA CHAR(4000), NAZWA_INSTYTUCJI CHAR(4000), KOD CHAR(4000), MIEJSCOWOSC CHAR(4000), ADRES CHAR(4000), NAZWISKO_I_IMIE CHAR(4000), FUNKCJA CHAR(4000), TEL_SLUZB_STACJON_1 CHAR(4000), TEL_SLUZB_STACJON_2 CHAR(4000), TEL_SLUZB_STACJON_3 CHAR(4000), TEL_SLUZB_KOM_1 CHAR(4000), TEL_SLUZB_KOM_2 CHAR(4000), FAX_SLUZB_1 CHAR(4000), FAX_SLUZB_2 CHAR(4000), EMAIL_SLUZB_1 CHAR(4000), EMAIL_SLUZB_2 CHAR(4000), WWW CHAR(4000), TYP CONSTANT "Biura wyborcze.", ODI_SESJA_ID CONSTANT "20130717144702" ODI_STATUS CONSTANT "0", IMIE EXPRESSION "pg_odi_utils.zwroc_imiona(pg_odi_utils.usun_przyrostki(:NAZWISKO_I_IMIE),0)", NAZWISKO EXPRESSION "pg_odi_utils.zwroc_nazwisko(pg_odi_utils.usun_przyrostki(:NAZWISKO_I_IMIE),0)" ) </code></pre> <p>There are 31 files like this. I need to replace value in this line:</p> <pre><code>ODI_SESJA_ID CONSTANT '20130717144702' </code></pre> <p>to new timestamp, the same for all files. Current timestamp is not known (I mean value that exists in file currently, in this case '20130717144702').</p> <p>So I need to (for each file found in directory):</p> <ul> <li>find line starting from ODI_SESJA_ID</li> <li>replace value after 'ODI_SESJA_ID CONSTANT ' with new one</li> <li>the rest lines in file should stay untouched</li> </ul> <p>What is the best way to do this using bash? Should I use sed or similar tools? How? </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload