Sponsored Content
The Lounge What is on Your Mind? Speculative Shell Feature Brainstorming Post 302514403 by Corona688 on Friday 15th of April 2011 03:29:19 PM
Old 04-15-2011
Another way to handle anonymous files could be similar to the awk way. When you redirect a file in awk, it stays open, referring to the same filename later just gets you the same handle over and over.

Code:
LINE=1
# Read lines from "otherfile" and "cmpfile" one by one, without
# redirecting the entire loop's stdin.
# Also set the close-on-exec flag for files opened in this fashion.
while read LINE <<"otherfile" && read OTHERLINE <<"cmpfile"
do
        if [ "$LINE" != "$OTHERLINE" ]
        then
                echo "Line $LINE doesn't match"
                echo "What would you like to do?"

                read RESPONSE
                case "${RESPONSE}" in
                *)   # todo: something
                      ;;
                 esac
        fi
        ((LINE++))
done

close "cmpfile" "otherfile"

Using << for 'keep the file open' seems a nice opposite of the >> 'append to file' redirection. This breaks the syntax for here-documents though. Not quite sure how to get the FD out of that either, maybe $<"filename" ?

Last edited by Corona688; 04-15-2011 at 04:35 PM..
 

4 More Discussions You Might Find Interesting

1. SCO

BASH-like feature. is possible ?

Greetings... i was wondering if there is any shell configuration or third party application that enables the command history by pressing keyboard up arrow, like GNU/BASH does or are there an SCO compatible bash versio to download? where ? just wondering (sory my stinky english) (2 Replies)
Discussion started by: nEuRoMaNcEr
2 Replies

2. Shell Programming and Scripting

Creating a command history feature in a simple UNIX shell using C

I'm trying to write a history feature to a very simple UNIX shell that will list the last 10 commands used when control-c is pressed. A user can then run a previous command by typing r x, where x is the first letter of the command. I'm having quite a bit of trouble figuring out what I need to do, I... (2 Replies)
Discussion started by: -=Cn=-
2 Replies

3. UNIX for Dummies Questions & Answers

brainstorming automated response

I am managing a database of files for which there is a drop-box and multiple users. what i would like to do is set a criteria for files coming into the drop-box based on file structure. (they must be like this W*/image/W*-1234/0-999.tif) If the files do not match the criteria i want them to be... (1 Reply)
Discussion started by: Movomito
1 Replies

4. UNIX for Beginners Questions & Answers

Can we create any check-point feature in shell ?

I have a script as below and say its failed @ function fs_ck {} then it should exit and next time i execute it it should start from fs_ck {} only Please advise #!/bin/bash logging {} fs_ck {} bkp {} dply {} ## main function### echo Sstarting script echo '####' logging fs_ck... (3 Replies)
Discussion started by: abhaydas
3 Replies
XtVaGetApplicationResources()											     XtVaGetApplicationResources()

Name
  XtVaGetApplicationResources - retrieve resources for the overall application using varargs argument style.

Synopsis
  void XtVaGetApplicationResources(object, base, resources, num_resources, ..., NULL)
	   Widget object;
	   XtPointer base;
	   XtResourceList resources;
	   Cardinal num_resources;

Inputs
  object    Specifies  the  object that identifies the resource database to search (the database is that associated with the display for this
	    object); may be of class Object or any subclass thereof.

  base	    Specifies the address of structure into which the resources will be written.

  resources Specifies the resource list for the subpart.

  num_resources
	    Specifies the number of resources in the resource list.

  ..., NULL A NULL-terminated variable-length list of resource name/value pairs to override any other resource specifications.

Availability
  Release 4 and later.

Description
  XtVaGetApplicationResources() obtains values for the resources described by resources, from the variable-length argument list, the resource
  database,  or  from the default values associated with each resource, and stores these values into the structure pointed to by base.	It is
  identical to XtGetApplicationResources() except that the args array of resource names and values and the num_args argument of that function
  are replaced with a NULL-terminated variable-length argument list.

  See  XtGetApplicationResources()  for more information on this function.  See XtVaSetValues() for more information on using variable-length
  argument lists to specify resources.

See Also
  XtGetApplicationResources(1), XtVaGetSubresources(1), XtVaSetValues(1).

Xt - Resource Management											     XtVaGetApplicationResources()
All times are GMT -4. The time now is 06:11 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy