The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #6 (permalink)  
Old 01-24-2008
radoulov's Avatar
radoulov radoulov is online now Forum Staff  
addict
  
 

Join Date: Jan 2007
Location: Варна, България / Milano, Italia
Posts: 2,926
As far as the entire task is concerned:


Code:
awk 'FNR == 1 {
  system("[ -f \""fnt"\" ]&&mv "fnt" "fn)
  fn = FILENAME
  fnt = FILENAME"__"++c
}
ORS = /;$/ ? RS : FS {
  sub(/;$/,"")
  print > fnt
} END {
  system("[ -f \""fnt"\" ]&&mv "fnt" "fn)
}' filenames*

Use nawk or /usr/xpg4/bin/awk on Solaris.