![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Advanced & Expert Users Advanced UNIX and Linux questions go here. Expert-to-Expert. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Named PIPE | Tamil | UNIX for Dummies Questions & Answers | 2 | 01-17-2007 12:20 AM |
| using pipe in a loop | netman | High Level Programming | 3 | 01-04-2006 11:30 PM |
| Truncated with a pipe? | TheCrunge | Shell Programming and Scripting | 1 | 11-14-2005 03:35 PM |
| PIpe Spy | jodders | High Level Programming | 11 | 02-18-2004 07:44 AM |
| pipe help | bb666 | High Level Programming | 5 | 02-26-2002 01:07 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
need help to put pipe(|) in between characters
Hi,
I need to put | bet ween every 3 characters in a string. InString = abcd12342 Out = abc|d12|342 Thanks |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
if you have PHP
Code:
# printf "abcd12342" | php5 -r 'echo implode("|",(str_split(file_get_contents("php://stdin"),3)));'
abc|d12|342
|
|
#3
|
|||
|
|||
|
for Perl, you can use this if you're going from and to files:
Code:
#!/usr/bin/perl
# You may need to change this path to /usr/local/bin/perl
local $/ = \3 ;
open (FILE,"in.txt");
while(<FILE>) {
$out .= $_ . "|";
}
close (FILE);
open (FILE,">out.txt");
print FILE "$out";
close (FILE);
exit;
|
|
#4
|
||||
|
||||
|
Try...
Code:
$ echo abcd12342 | fold -3 | paste -s -d '|' abc|d12|342 |
||||
| Google The UNIX and Linux Forums |