07-08-2008
file redirection problem
my querry is
suppose i have duplicate std i/p with FD-3 --exec 0<&3
now redirected std i/p to a file ----exec 0<file1
suppose i am reading the file line by line --while read LINE
cutting some fields and comparing it with a variable and if a match is found
then i have to read new values from the user .
But as std i/p is already redirected
I regain it from FD-3---exec 3<&0
now i read two values ..say read var1;read var2
now i want to again redirect it to the source file and read the next line but the read pointer is going to the top of the file but i want to go to the nextline
can any one tell me how can i preserve the pointer position so that after reviving it , it points to the next line in my file1.
Check the below program if you need an idea
-:my program:-
echo "Enter the friend whose data u want to change ?"
read FRIEND
exec 3<& 0
exec 0<"$DIR/database"
while read LINE
do
candidate=$(echo $LINE | cut -d ' ' -f1)
birthday=$(echo $LINE | cut -d ' ' -f2)
#mobileno=$(echo $LINE | cut -d ' ' -f3)
if [ "$candidate" = "$FRIEND" ] ;then --> match found
exec 0<& 3 -->regaining std i/p
exec 3<&-
echo "Edit your friend's name" --> reading from user
read NAME
echo "Edit your Friend's B'day"
read BIRTHDAY
echo " $NAME $BIRTHDAY">>database1
exec 3<&0 -->again redirecting to the file named database and through the loop reading the next line
exec 0<"$DIR/database"
else
echo " $candidate $birthday">>database1
fi
done
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
Hi,
I am doing this perl script
print (@line(1..15));
the lines 1 to 15 get printed...
how can i redirect this to file?
thanks and regards
vivek.s (4 Replies)
Discussion started by: vivekshankar
4 Replies
2. UNIX for Dummies Questions & Answers
I was simply trying to redirect some output in a log file but it foxed me.
truss a.out > log
It gave only the output of the a.out which was only a simple print "Hello"
Then I tried
truss a.out 2&1>a
echo `truss a.out` > a
All failed.
What am i missing.
Thanks (7 Replies)
Discussion started by: vibhor_agarwali
7 Replies
3. Shell Programming and Scripting
Hello Experts,
I am facing the following problem ..
>cat my_file prints
initial begin
StartSim;
LDR(on); // Lock Detect Enable
But when I trying the same with the following command it shows me all the line in the same line.Like
... (4 Replies)
Discussion started by: user_prady
4 Replies
4. Shell Programming and Scripting
hi all,
how to redirect the stdout msg in command line and file at the same time?
e.g
i got the script named test.sh, content as following:
#!/bin/sh
echo "111"
when i run the script ./test.sh > log.log, it will wirte the "111" into log.log, but how to show the "111" in command line... (2 Replies)
Discussion started by: eric_wong_ch
2 Replies
5. Shell Programming and Scripting
hi
i want a solution for the fallowing:
i am redirecting output from bash script in which we are running background commands like
./test.sh
contains
ls -l &
ps
when we do as
./test.sh 1> test.txt 2>&1
but test.txt not containing output as ls -l and ps.
it showing ls -l, ps and... (2 Replies)
Discussion started by: indianwomen
2 Replies
6. Shell Programming and Scripting
Hi all,
Maybe someone is able to help:
Need to redirect the output of a command in realtime to a second command. Command-A executes a remote shell to another host, and outputs its results. Command-B displays a "dialog" with the outputs of Command-A.
Command-A Output:
Updating FileA... (2 Replies)
Discussion started by: mharald
2 Replies
7. Shell Programming and Scripting
Hi,
I have to migrate Korn Shell who call Sybase command into Oracle Command.
I have a problem on this example :
DATNUM=$(
sqlplus -S SA/SASASA@MIGGVDEV <<!
SET FEEDBACK OFF;
SET HEADING OFF;
select sybase_utilities.datediff('DAY', '01/01/1900', '01/01/2000') from... (4 Replies)
Discussion started by: buzzy1804
4 Replies
8. Shell Programming and Scripting
Hi All,
i m facing very strange problem . like suppose i am in one directory and then i type ls
it will display the content of directory then i redirect the output as
sneha-pardus $ ls > test
sneha-pardus $ cat test
a.sh b.sh c.sh
sneha-pardus $ awk ' { print $1 } ' test > test... (3 Replies)
Discussion started by: aishsimplesweet
3 Replies
9. UNIX for Dummies Questions & Answers
I almost reach my objective (Youhouuu !!!!)
But I really don't understand why it doesn't work until the end... :wall:
For clarity's sake I am taking a very simple example. The operations I am doing in the script (gsub and print) really don't have any importance !!! I just matter about... (10 Replies)
Discussion started by: beca123456
10 Replies
10. Shell Programming and Scripting
I've got a problem with file redirection in bash, in loop while (in my script done < bufor.txt). In every consecutive iteration there's a possibility that to the bufor.txt will be added some lines. Unfortunately, in loop, added lines are ignored (for example: bufor.txt has 5 lines, in 3rd iteration... (4 Replies)
Discussion started by: kk9
4 Replies
LEARN ABOUT CENTOS
__gnu_profile::__trace_vector_to_list
__gnu_profile::__trace_vector_to_list(3) Library Functions Manual __gnu_profile::__trace_vector_to_list(3)
NAME
__gnu_profile::__trace_vector_to_list -
SYNOPSIS
Inherits __gnu_profile::__trace_base< __vector2list_info, __vector2list_stack_info >.
Public Member Functions
void __add_object (__object_t object, __vector2list_info__info)
void __collect_warnings (__warning_vector_t &__warnings)
void __destruct (const void *__obj)
__vector2list_info * __find (const void *__obj)
__vector2list_info * __get_object_info (__object_t __object)
void __insert (__object_t __obj, __stack_t __stack)
void __invalid_operator (const void *__obj)
float __list_cost (std::size_t __shift, std::size_t __iterate, std::size_t __resize)
void __opr_find (const void *__obj, std::size_t __size)
void __opr_insert (const void *__obj, std::size_t __pos, std::size_t __num)
void __opr_iterate (const void *__obj, std::size_t __num)
void __resize (const void *__obj, std::size_t __from, std::size_t __to)
void __retire_object (__object_t __object)
float __vector_cost (std::size_t __shift, std::size_t __iterate, std::size_t __resize)
void __write (FILE *__f)
Protected Attributes
const char * __id
Detailed Description
Vector-to-list instrumentation producer.
Definition at line 158 of file profiler_vector_to_list.h.
Author
Generated automatically by Doxygen for libstdc++ from the source code.
libstdc++ Tue Jun 10 2014 __gnu_profile::__trace_vector_to_list(3)