Help for this page

Select Code to Download


  1. or download this
    awk -v RS='' -v ORS='\n\n' '/^[^ ].*$/' file.txt | awk -v RS='' 'NR==1
    +{print $0}'
    
  2. or download this
    perl -0pe 's/.*?\n*?([^ \n].*?)\n\n.*/$1/gs' file.txt
    
  3. or download this
    perl -0pe 's/([^ \n].*?)\n\n.*/$1/gs' file.txt
    
  4. or download this
    perl -0pe 's/.*?\n([^ \n].*?)\n\n.*/$1/gs' file.txt
    
  5. or download this
    if ( $. == 1 and /^[^ ].*$/ ) {...}
    
  6. or download this
    echo '' > tempfile.txt ; cat file.txt >> tempfile.txt ; perl ...
    
  7. or download this
    if [[ $(egrep -n -m1 -e '^[^ ]' file.txt | sed 's/^\([0-9]\+\):.*/\1/g
    +') -eq 1 ]] ; then perl ... ; else perl ... ; fi