03-08-2008
That was a typo on my part in the example. However, the read a1 b1 c1 didn't resolve the issue. I do have it correct in my code (granted I called it s/thing totally different).
For the grep issue also, I'm wondering if the input file, when opened by a "while read", is in memory and when you do a grep of that file that has been read to a certain point, there's still a pointer in memory to that input file so then grep only sees everything after that first occurrence?
The first occurrence is like getting to the first '2' in Perderabo's example (a 'key word' I'm interested in doing more with) and trying to pull all '2's from the input file (countfile) again but grep doesn't see the first '2' anymore in the inner while...it only pulls the 2nd, 3rd, 4th occurrence, etc. when I sent the output to tmpcountfile ( grep $x countfile > tmpcountfile .... while read a1; do s/thing done<tmpcountfile).
It's hard to explain but I tried simple tests and it confirmed my issue with inner while. I opened the inner while tmpcountfile and the first occurrence is not an output from the grep when done within the inner while.
...
Gianni
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi
I am using while loop, below, to read lines from a very large file, around 400,000 rows. The script works fine until around line 300k but then starts giving incorrect result.
I have tried running the script with a smaller data set and it works fine. I made sure to include the line where... (2 Replies)
Discussion started by: saurabhkumar198
2 Replies
2. Shell Programming and Scripting
Hi,
I'm trying to run the following command using sh -c
ie
sh -c "while read EachLine
do
rm -f $EachLine ;
done < file_list.lst;"
It doesn't seem to do anything.
When I run this at the command line, it does remove the files contained in the list so i know the command works
ie... (4 Replies)
Discussion started by: chrispward
4 Replies
3. UNIX for Advanced & Expert Users
Hi! I've got a problem with reading from serial port, when I run this code on Digi ConnectCore Wi-9c. But writing to serial port is Ok. By the way, when I'm running this code on "full" Linux it is working Ok - I can read and write to serial without mistakes. Where is a problem?
uname -a:... (3 Replies)
Discussion started by: Japonomatj
3 Replies
4. Shell Programming and Scripting
Hi,
This is the script and the error I am receiving
Can anyone please suggest ?
For the exmaple below assume we are using vg01
#!/bin/ksh
echo "##### Max Mount Count Fixer #####"
echo "Please insert Volume Group name to check"
read VG
lvs |grep $VG | awk {'print $1'} > /tmp/audit.log
... (2 Replies)
Discussion started by: galuzan
2 Replies
5. Shell Programming and Scripting
I'm using while read in a script to create a file but when I paste on the screen it echos out different than the data. The file is created correctly and the script does as it should. Just trying to resolve what's being show on the screen.
while read FILES
do
echo... (3 Replies)
Discussion started by: toor13
3 Replies
6. Shell Programming and Scripting
Hi,
I have a situation where i need to read line by line from a text pad and with each line , i need to take inputs from command line and do some process.
Using below code i am not able to use 'read' keyword twice.
Can any one please help
cat > t.txt
a
d
c
> cat > t.ksh
while read... (4 Replies)
Discussion started by: Ravindra Swan
4 Replies
7. Shell Programming and Scripting
Heyas
With my forum search term 'issue with leading dash' i found 2 closed threads which sadly didnt help me.
Also me was to eager to add the script, that i didnt properly test, and just now figured this issue.
So i have this code:
if ]
then while read line
do line="${line/-/'\-'}"... (7 Replies)
Discussion started by: sea
7 Replies
8. Shell Programming and Scripting
Hello,
I have used a chunk of ksh script similar to this in many places without any issue:
while :
do
print;
read OPTION?"Enter a number (q to quit): "
expr ${OPTION} + 1 >/dev/null 2>&1
CHECKVAL=$?
if }" != ${OPTION} ]; then
... (2 Replies)
Discussion started by: port43
2 Replies
9. Shell Programming and Scripting
hi all.
my loop is getting failed eventhoug it is 1=1 but it is failure message.
any help plz
Output expected :
echo "sucesss"
code
out=`cat bit.txt`
if ];
then
echo "sucess"
else
echo "Failure" (2 Replies)
Discussion started by: arun888
2 Replies
10. Shell Programming and Scripting
Hello,
I have an ffmpeg bash script which is working nice and
I need to do the same for other sources.
To create new scripts and to deal with multiple bash files sounds not logical. It is a bit hard to manage for me..
I wondered if it was possible to make my input file as variable.
Then I... (1 Reply)
Discussion started by: baris35
1 Replies