![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Need to serach if a new line character exists on the last line in a file | sunilbm78 | UNIX for Dummies Questions & Answers | 10 | 02-29-2008 11:15 AM |
| batch delete using find, files with # character | tphyahoo | UNIX for Dummies Questions & Answers | 0 | 05-30-2006 09:05 AM |
| Find files which contain a null character | Bab00shka | UNIX for Dummies Questions & Answers | 5 | 12-16-2005 07:41 AM |
| delete a line based on first character of the line | borncrazy | UNIX for Dummies Questions & Answers | 2 | 12-06-2005 12:27 PM |
| end of the line character | zomboo | Shell Programming and Scripting | 5 | 12-30-2004 02:30 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
need to find last character in each line in all files
Hi,
I need to read each line in all files .If last character in each line is not ;(semicolon) then i need to append next line also.Here each line may consists of multiple semicolons( How to achieve this? For example my file consists of asdfgh;adffg;afdfg; adfsffvfgggg; aedfdsfs fsff; Here i need output as asdfgh;adffg;afdfg adfsffvfgggg aedfdsfs fsff How to achieve this? |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
if you have GNU sed:
Code:
sed -i 's/;$//' file* Code:
perl -pi -e 's/;$//' file* |
|
#3
|
|||
|
|||
|
Hi,
If there is no semicolon its not appending next line with present line.And also its not working if my file contains pipe line characters like '|'. For example if file contains user|find|ghjk|gg|; sufgh|fghj|hgj Dhj|hjk|jkl; its not removing semicolon and its not appending 3red line to 2nd line |
|
#4
|
|||
|
|||
|
try this
sed -e :a -e '/;$/!N;s/\n//; ta' -e 's/;$//' file |
|
#5
|
||||
|
||||
|
Code:
awk 'ORS=/;$/?RS:FS{sub(/;$/,"")}1' filename
|
|
#6
|
||||
|
||||
|
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*
|
|
#7
|
|||
|
|||
|
Hi quintet
using this sed -e :a -e '/;$/!N;s/\n//; ta' -e 's/;$//' file its not redirecting to my directory again |
|||
| Google The UNIX and Linux Forums |
| Tags |
| perl, sed |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|