Search Results

Search: Posts Made By: greenworld123
1,749
Posted By bakunin
I think you have already gotten very good advice...
I think you have already gotten very good advice about how to solve it but it might be helping you to understand what is going on:

When a process "opens" a file it calls some OS function (namely...
1,749
Posted By RudiC
WHAT is the garbage? What is correct after that? ...
WHAT is the garbage? What is correct after that?
If I get you correctly, the truncation works correctly, and the old log file contents is lost.
Does the process keep the old file open? Check with...
1,749
Posted By rbatte1
Oh, now I see. Sorry, I was confused by your...
Oh, now I see. Sorry, I was confused by your phrase "redirecting to null" You have tried to truncate the file separately. The problem you might have is that the file is still open by your running...
17,926
Posted By Franklin52
Yes, misread something... in that case: awk...
Yes, misread something... in that case:
awk 'NF=NF+1' OFS="|" file
17,926
Posted By Franklin52
With awk: awk '$1=$1' OFS="|" file
With awk:
awk '$1=$1' OFS="|" file
1,498
Posted By hanson44
It would be better if you could post some...
It would be better if you could post some complete lines. But no matter.

create index has one space.
create unique index has two spaces.

Your regular expression specifies at least two spaces...
3,882
Posted By hanson44
$ cat temp.sh length=15 value="1234567890" ...
$ cat temp.sh
length=15
value="1234567890"
printf "%0*d\n" $length "$value"

$ ./temp.sh
000001234567890
3,882
Posted By guruprasadpr
For zero padding in ksh, use the typeset command:...
For zero padding in ksh, use the typeset command:

$ typeset -RZ5 x
$ x=25
$ echo $x
00025

Mapping it to your case:
$ length=15
$ value="1234567890"
$ typeset -RZ${length} value
$ echo...
3,882
Posted By guruprasadpr
You can do it like this: printf "%15s\n" ...
You can do it like this:

printf "%15s\n" "$value"


For dynamic:
printf "%*s\n" $length "$value"

Guru.
85,913
Posted By elixir_sinari
With sed: sed 's/^\(.\{149\}\)./\1X/' inputfile
With sed:
sed 's/^\(.\{149\}\)./\1X/' inputfile
16,228
Posted By balajesuri
1s/\(^.\{17\}\).\{8\}\(.*\)/\1some123text\2/ -->...
1s/\(^.\{17\}\).\{8\}\(.*\)/\1some123text\2/ --> '1s' refers to substitution only in the first line. First 17 characters (matched by pattern in green) are stored in buffer, referenced by \1. The next...
16,228
Posted By balajesuri
sed...
sed '1s/\(^.\{17\}\).\{8\}\(.*\)/\1some123text\2/; /^5900/s/\(^.\{4\}\).\{13\}\(.*\)/\1some123text\2/' inputfile
6,745
Posted By balajesuri
The Perl way. $ echo "123" | perl -e...
The Perl way.
$ echo "123" | perl -e 'chomp($x=<>);$pad_chr="0";$len=3; print $x . ($pad_chr x $len)'
123000

Sans redundance.
$ echo "123" | perl -e 'chomp($_=<>);print $_ .("0"x3)'
123000
6,745
Posted By ahamed101
Traditional way! echo 12121 | awk '{printf...
Traditional way!

echo 12121 | awk '{printf $0;while(len-->0){printf char}}' len=5 char=9


HTH
--ahamed
2,585
Posted By birei
One possible way: $ cat infile 030150678 ...
One possible way:

$ cat infile
030150678 bos 00156 0500405612 23 23
$ sed 's/^\(.\{3\}\)\(.\{5\}\)\(.\)\(.\{9\}\)\(.\{7\}\)\(.\{2\}\).*/\1|\2|\3|\4|\5|\6/' infile
030|15067|8| ...
2,585
Posted By birei
Hi greenworld123, Try next 'perl' program: ...
Hi greenworld123,

Try next 'perl' program:

$ cat script.pl
use warnings;
use strict;

while ( <DATA> ) {
chomp;
printf qq[%s\n], join ( qq[|], unpack( qq[A3 A5 A1 A9 A7...
1,852
Posted By MSMario
put variables $x in quotes if [ "$x" == "A" ];...
put variables $x in quotes
if [ "$x" == "A" ]; then
t=$[t+1];
a=$y;
elif [ "$x" == "B" ]; then
t=$[t+3];
b=$y;
elif [ "$x" == "C" ]; then
here is my...
Showing results 1 to 17 of 17

 
All times are GMT -4. The time now is 02:35 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy