Tag Info

New answers tagged

0

You can use bash expansion: ${RPT_DT%${RPT_DT#* * }}$'\n'${RPT_DT#* * }


1

(hopefully) the final product find . -name \*.gz -type f -exec gzcat {} + | sed -ne'/^ *ID:/h;/No Profile/!d;x' \ -e's/^ *ID:\([^ ]*\).*/\1/p' So that will recursively find all of the regular files rooted in the current directory with filenames which match the pattern *.gz and call zcat as few times as is necessary to iteratively uncompress every ...


2

Edited New approach: removing line breaks. Assuming that you have only one ID per gzipped file, you can try the following: gunzip -c file.gz | sed -e ':a;N;$!ba;s/\n/ /g' -e '/^[[:space:]]/d' -e 's/^ID:\([[:alnum:]]*\).*Warning - No Profile Data.*/\1/' -e '/^ID:/d' gunzip -c extracts the file to stdout sed collapses all lines into one, then removes all ...


2

You could work with awk instead: zcat file.gz | awk '/No Profile Data/{printf "%s\n%s\n%s\n", b, a, $0} {b=a;a=$0}' zcat prints the content of the gzipped file to the standard output awk then searches for the string "No Profile Data" and prints the two previous lines


0

As HP-UX does not have bash (available from third party), you can use globs instead of regex. This works with both sh and ksh on HP-UX e.g. if [[ ${Y} = @(ERROR|ORA-)* ]] ; then exit 1 fi



Top 50 recent answers are included