Hi Rudi,
Thanks for your reply.
I just want to read the input file by using any code inside the shell script so that the script automatically reads the file and store it in a variable.
As of now i have followed the below in my shell script.
#!/bin/ksh
(
echo "Enter the sync: \c"
read sync
echo "Enter the input: \c"
read Input1
egrep -iv ''$sync' 513|'$sync' 519|'$sync' 532|'$sync' 540|'$sync' 563|'$sync' 566|'$sync' 632|'$sync' 669|'$sync' 686|'$sync' 789|'$sync' 810|'$sync' 811|'$sync' 855|'$sync' 866' $Input1 > test2
cat test2 CR > op.diaryests.4avg.$sync.total.try
sort -o op.diaryests.4avg.$sync.total.try op.diaryests.4avg.$sync.total.try
exit
)
I need to read six different files and apply some grep
and cat
and sort
commands. So instead of asking the user to enter six files manually, i want the script to read the file from the path when it executed.
Is there any way to read the input file instead of the way i used in the script ?
Hope i am clear on my specifications.
Thanks in advance.
---------- Post updated at 09:49 AM ---------- Previous update was at 09:44 AM ----------
Hi Ravindhar,
I am sorry, may be i am not clear on my specifications.
Below is the script which i wrote.
#!/bin/ksh
(
echo "Enter the sync: \c"
read sync
echo "Enter the input: \c"
read Input1
egrep -iv ''$sync' 513|'$sync' 519|'$sync' 532|'$sync' 540|'$sync' 563|'$sync' 566|'$sync' 632|'$sync' 669|'$sync' 686|'$sync' 789|'$sync' 810|'$sync' 811|'$sync' 855|'$sync' 866' $Input1 > test2
cat test2 CR > op.diaryests.4avg.$sync.total.try
sort -o op.diaryests.4avg.$sync.total.try op.diaryests.4avg.$sync.total.try
exit
)
In the above, i am reading the input by asking user to enter manually when running the shell script. Instead of that, i want the shell script to read the Input file from the path and store it in a variable 'Input1'
.
By using the while
loop or Input1 = `cat /path/filename/`
, i am unable to do it. I am getting a message "Input1 not found"
.
Like the above , i have to read six different files and execute same grep
and cat
commands. So i want to put all of the code in one shell script. Instead of asking user manually to enter six times six different input files, i want the script to read it on its own.
Hope i am clear this time.
Please let me know if you need further any more information.
Thanks in advance.