So I must write a ksh/sh script who read character at a position in a File. So also it must read all the lines who belongs at these characters , then write these lines in a another File.
Can you help me , or give little councils to advance with my script.
I am afraid you won't make it in a ksh-shell script.
You need to use Perl for this, it's installed on almost each system by default. It might depend on the OS-type which version you have.
If I understand your question right a solution in Perl would be :
Thanks for your response , it will be very good idea but i need that the script must be in ksh.
So I have done 10 years VB script , so I have program this script in 30 mn in VB, and I need a very long time in unix script.
So our system is HP-Unix 11i.
I need ksh script , because others users must execute this script, and this script is a little part of a big script who must take files in a lot of directories. I have done this part of the script.
Perhaps do you have Internet Site where I can found those examples of scripts.
So I can program in ksh to read lines of a file , but i don't know how to take a part of the file = characters I have found and write it in a other file.
I must let you know that I think it is not possible at all what you want. I am afraid that you do need to do it in another language than shell-scripting.
You do should be aware that you can call a perl-script (also users) from an excisting script. f.e. :
#!/bin/ksh
#
perlroutine="set"
if [ -z "$perlroutine" ]
then
exec /path/to/my/perlscript.pl param1 param2 param3
fi
echo "Alright perl routine is completed"
# ---------------------------------------------
#!/usr/local/bin/perl
#
# Perlroutine script henced by ksh-shell script
#
$param1=$1;
$param2=$2;
$param3=$3;
I realy hope someone else will give you another solution in ksh (I'dd be very interested !!), but I am afraid no-one can.
I am not real sure of what steiner wants to do. But if I understand that perl script (and I may not), in ksh it would roughly be:
#! /usr/bin/ksh
exec < /path/to/inputfile
exec > /path/to/outfile
wanted="x"
IFS=""
while read line ; do
if [[ line = *${wanted}* ]] ; then
echo "$line"
fi
done
exit 0