Sponsored Content
Top Forums Shell Programming and Scripting Update file record inside read loop Post 302742623 by ysrini on Tuesday 11th of December 2012 10:52:15 AM
Old 12-11-2012
Update file record inside read loop

Hi,
I am reading file records inside a while loop,
and want to update the record when certain condition is met.
How can I update a file while being read?
I want to avoid using temporary files, copy, rename, ...

Code:
while IFS=',' read -r f1 f2
do

  function(f1,f2)
  if [ $? -eq 1 ]
  then
     <add field 'ok' as 3rd field to this record in the file>
  fi

done < ${INPUT_FILE}

Thanks,
-sri
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

read inside a while loop

Hi all, In a while loop, like below... while read line do read choice case $choice in 1) echo "xxx" esac done < file why I can't run the read choice???? (3 Replies)
Discussion started by: dta4316
3 Replies

2. Shell Programming and Scripting

input inside while read loop

Hi all Does anyone have a script that will allow me to stop inside a while read loop. I want to pause the loop until a enter is pressed. e.g. While read line do echo something if LINECOUNT > 40 then read ENTER?"PRESS ENTER TO CONT..." ... (3 Replies)
Discussion started by: jhansrod
3 Replies

3. UNIX for Dummies Questions & Answers

how to read record by record from a file in unix

Hi guys, i have a big file with the following format.This includes header(H),detail(D) and trailer(T) information in the file.My problem is i have to search for the character "6h" at 14 th and 15 th position in all the records .if it is there i have to write all those records into a... (1 Reply)
Discussion started by: raoscb
1 Replies

4. Shell Programming and Scripting

read command (input) inside the while loop

Hi, 'read' command is not working inside the while loop, How can I solve this? Rgds, Sharif. (2 Replies)
Discussion started by: sharif
2 Replies

5. UNIX for Advanced & Expert Users

"while read ..." loop exiting after reading only one record

Greeting, The following script completes after reading only one record from the input file that contains many records. I commented out the "ssh" and get what I expect, an echo of all the records in the input.txt file. Is ssh killing the file handle? On the box "uname -a" gives "SunOS... (2 Replies)
Discussion started by: twk
2 Replies

6. Shell Programming and Scripting

how to pass a variable to an update sql statement inside a loop

hi all, i am experiencing an error which i think an incorrect syntax for the where clause passing a variable was given. under is my code. sqlplus -s ${USERNAME}/${PASSWORD}@${SID} << END1 >> $LOGFILE whenever sqlerror exit set serveroutput on size 1000000 declare l_rc ... (0 Replies)
Discussion started by: ryukishin_17
0 Replies

7. Shell Programming and Scripting

Unable to read the first space of a record in while loop

I have a loop like while read i do echo "$i" . . . done < tms.txt The tms.txt contians data like 2008-02-03 00:00:00 <space>00:00:00 . . . 2010-02-03 10:54:32 (2 Replies)
Discussion started by: machomaddy
2 Replies

8. Shell Programming and Scripting

For loop inside awk to read and print contents of files

Hello, I have a set of files Xfile0001 - Xfile0021, and the content of this files (one at a time) needs to be printed between some line (lines start with word "Generated") that I am extracting from another file called file7.txt and all the output goes into output.txt. First I tried creating a for... (5 Replies)
Discussion started by: jaldo0805
5 Replies

9. Shell Programming and Scripting

ksh while read loop breaks after one record - AIX

#!/bin/ksh for SRV in imawasp01 \ imawasp02 \ imawasp03 \ imawasp04 \ imawasp05 \ imawasp06 \ imawasp07 \ imawasp08 \ imawasp09 do print "${SRV}" while read PASSLINE do SRVNAME=`echo ${PASSLINE} | awk -F\: '{print $1}'` LASTLOGIN=`ssh ${SRV} lsuser ${SRVNAME} | tr '... (2 Replies)
Discussion started by: port43
2 Replies

10. Shell Programming and Scripting

Unable to read user input inside a loop

Hi, This query is a part of a much more lengthy script. I wish to look for all the files in a folder named "data" which in this case has two files i.e. plan.war and agent.properties. For all the files found under data I wish to ask the user as to where they wish copy the files to. Below,... (14 Replies)
Discussion started by: mohtashims
14 Replies
bcron-update(8) 					      System Manager's Manual						   bcron-update(8)

NAME
bcron-update - Update system crontabs. SYNOPSIS
bcron-update path [ path ... ] DESCRIPTION
bcron-update polls the named files or directories periodically to see if there are any new, changed, or removed files. When it detects changes, it mirrors those changes into the crontab spool directory. bcron-update runs as root in order to be able to read system files that would potentially be unreadable otherwise. On Debian, if path is a directory, bcron-update skips files in this directory with names that do not solely consist of lower- and uppercase letters ('a'-'z', 'A'-'Z'), digits ('0'-'9'), underscores ('_'), and hyphens ('-'). EXAMPLES
To mirror modern vixie-cron's behavior, use: bcron-update /etc/crontab /etc/cron.d ENVIRONMENT
BCRON_SPOOL The spool directory for bcron. Defaults to /var/spool/cron. BCRON_USER After writing files and before moving them into their final location, bcron-update changes the ownership of the file to this user so that bcron-sched can read them. SEE ALSO
bcron-sched(8) DIAGNOSTICS
bcron-update outputs three different kinds of messages about actions it is taking. Rescanning /etc/cron.d The named directory has been modified, and will be scanned to determine what files have been added or deleted. -/etc/cron.d/oldfile The named file no longer exists and will be removed from the spool. +/etc/cron.d/newfile The named file was either created or modified since the last scan, and will be copied into the spool. AUTHOR
Bruce Guenter <bruceg@em.ca> bcron-update(8)
All times are GMT -4. The time now is 10:19 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy