![]() |
|
|
|
|
|||||||
| 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 |
| Script to Extract time from log files and write to a excel | santosham | UNIX for Dummies Questions & Answers | 4 | 06-09-2008 06:30 AM |
| Script to Extract time from log files and write to a excel | santosham | UNIX for Advanced & Expert Users | 0 | 06-06-2008 10:27 AM |
| shell script to remove old files and write to a log file | yabai | Shell Programming and Scripting | 3 | 05-21-2008 12:52 AM |
| how to read or write device files | sriram.ec | UNIX for Dummies Questions & Answers | 1 | 01-03-2006 01:27 PM |
| How to read and write files one line at a time. | s_chopra | UNIX for Dummies Questions & Answers | 2 | 04-18-2001 06:39 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
|||
|
Script with read/write Files
Hello,
I am a Newbie in ksh Unix Script. 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. Thanks a lot... |
| Forum Sponsor | ||
|
|
|
|||
|
Response to your help
Hello David,
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. So thanks you very much for your help... Bye |
|
||||
|
Hi Steiner,
Sorry to not have been of any help. 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. @yourservice David |
|
||||
|
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:
Code:
#! /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
|
|
|||
|
Here the script in ksh for read/write file
Hello,
Thanks for your help with the few questions I ask to you. So i have finished the script in ksh for read and write datas from one files and split there in perhaps few anothers files. So here is the script : #--------------------------------------------------- # Look for I02 - files in /opt/rfts/basket/VEGA_I02 #--------------------------------------------------- find $INT_DIR -type f | egrep "I02.*.*.x.*" | while read file do filename=$( basename $file) C_NAME=$(echo $filename | cut -c,9-14) exec <$INT_DIR/${filename} while read line ; do if [ $(echo ${#line}) -gt 157 ] ; then exec 2>$INT_DATA_KCC_DMS$(echo $line | cut -c,158-160)/$TYPE_FILE$(echo $line | cut -c,158-160).$C_NAME exec 3>$INT_DATA_KCC_DMS$(echo $line | cut -c,158-160)/$TYPE_FILE$(echo $line | cut -c,158-160).$C_NAME.v.00 1 fi echo $line>&2 done done exit 0 So it's work very good. Thanks for all your help !!! |
|||
| Google The UNIX and Linux Forums |