Showing posts with label linux. Show all posts
Showing posts with label linux. Show all posts

Thursday, February 12, 2009

Join two lines in sed

I was trying to load a CSV file into an Oracle database using SQL*Loader today and came across an issue where some of the fields contained CR within the data. Luckily each field is enclosed with double quotes ". Knowing this I was able to run the folling sed command which finds any lines that do not end with a double quote and joins them to the next line.

sed -e :a -e '/[^\"]$/N; s/[^\"]\n//; ta' _
old_filename > new_filename

Just thought I'd share - someone might find it useful

Monday, November 10, 2008

ls: Arg list too long

Ever seen the error "arg list too long" when issuing an ls with a wildcard? The simple way round this is as follows:


find . -name "regexp" -exec ls -l '{}' +

Where:

regexp is the regular expression you are searching for