Sponsored Content
Top Forums Shell Programming and Scripting Bash script to read a file from particular line till required line and process Post 302924212 by Optimus81 on Friday 7th of November 2014 02:59:54 AM
Old 11-07-2014
Thanks junior-helper for the help.

Sorry i was struck with imp release.

Now am back.

I tried what you said but it doesn't do anything, script just run and comeback.

Code:
admin@HP1 # cat script.sh
#!/usr/bin/bash

ufile=$1 #user file name
#ulf=$2 #user line from
ulf=25 #user line from
ult=30 #user line to

ifile=$4 #item file name
ilf=$5 #item line from
ilt=$6 #item line to

for user in `awk -vULF=$ulf -vULT=$ult 'NR>=ULF && NR<=ULT' $ufile` ; do
 for item in `awk -vILF=$ilf -vILT=$ilt 'NR>=ILF && NR<=ILT' $ifile` ; do
  echo $user @ $item
 done
done

I have both itemlsit and userlist file with 100 lines data in each

admin@HP1 # wc -l userlist itemlist
100 userlist
100 itemlist
200 total

Am i missing something here ?

My OS is :
uname -a
SunOS HP1 5.10 Generic_144489-09 i86pc i386 i86pc

Please let me know
 

10 More Discussions You Might Find Interesting

1. Post Here to Contact Site Administrators and Moderators

how to read a file till it encounters a blank line

Hi , I want to read a file starting with "*" up to till it encounters a blank line and to redirect this output to a different file.Plz suggest how to write a script for this. e.g:- * PK Sent Email (11.23) CALYPSO 1243215 9116457 NEW TRAD FAILED Nov 23 2007 9:34AM OASYS: DPS:... (0 Replies)
Discussion started by: adityam
0 Replies

2. Shell Programming and Scripting

how to read a file till it encounters a blank line

Hi , I want to read a file starting with "*" up to till it encounters a blank line and to redirect this output to a different file.Plz suggest how to write a script for this. e.g:- * PK Sent Email (11.23) CALYPSO 1243215 9116457 NEW TRAD FAILED Nov 23 2007 9:34AM OASYS: DPS: SINGCORP invalid... (1 Reply)
Discussion started by: adityam
1 Replies

3. UNIX for Dummies Questions & Answers

how to read a file till it encounters a blank line

Hi , I want to read a file starting with "*" up to till it encounters a blank line and to redirect this output to a different file.Plz suggest how to write a script for this. e.g:- * PK Sent Email (11.23) CALYPSO 1243215 9116457 NEW TRAD FAILED Nov 23 2007 9:34AM OASYS: DPS: SINGCORP invalid... (1 Reply)
Discussion started by: adityam
1 Replies

4. UNIX for Advanced & Expert Users

Urgent Help required : awk/sed help to find pattern and delete till end of line

Hi, I need help with using an awk or sed filter on the below line ALTER TABLE "ACCOUNT" ADD CONSTRAINT "ACCOUNT_PK" PRIMARY KEY ("ACCT_ID") USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 STORAGE(INITIAL 65536 FREELISTS 1 FREELIST GROUPS 1) TABLESPACE "WMC_DATA" LOGGING ENABLE Look for... (1 Reply)
Discussion started by: rajan_san
1 Replies

5. Shell Programming and Scripting

bash: read file line by line (lines have '\0') - not full line has read???

I am using the while-loop to read a file. The file has lines with null-terminated strings (words, actually.) What I have by that reading - just a first word up to '\0'! I need to have whole string up to 'new line' - (LF, 10#10, 16#A) What I am doing wrong? #make file 'grb' with... (6 Replies)
Discussion started by: alex_5161
6 Replies

6. Shell Programming and Scripting

[Solved] Problem in reading a file line by line till it reaches a white line

So, I want to read line-by-line a text file with unknown number of files.... So: a=1 b=1 while ; do b=`sed -n '$ap' test` a=`expr $a + 1` $here do something with b etc done the problem is that sed does not seem to recognise the $a, even when trying sed -n ' $a p' So, I cannot read... (3 Replies)
Discussion started by: hakermania
3 Replies

7. Shell Programming and Scripting

Read file line by line and process the line to generate another file

Hi, i have file which contains data as below(Only sample shown, it may contain more data similar to the one shown here) i need to read this file line by line and generate an output file like the one below i.e based on N value the number of MSISDNs will vary, if N=1 then the following... (14 Replies)
Discussion started by: aemunathan
14 Replies

8. Shell Programming and Scripting

Shell script to read a text file line by line & process it...

Hi , I am trying to write an shell, which reads a text file (from a location) having a list of numbers of strictly 5 digits only ex: 33144 Now my script will check : 1) that each entry is only 5 digits & numeric only, no alphabets, & its not empty. 2)then it executes a shell script called... (8 Replies)
Discussion started by: new_to_shell
8 Replies

9. Shell Programming and Scripting

How to start reading from the nth line till the last line of a file.

Hi, For my reuirement, I have to read a file from the 2nd line till the last line<EOF>. Say, I have a file as test.txt, which as a header record in the first line followed by records in rest of the lines. for i in `cat test.txt` { echo $i } While doing the above loop, I have read... (5 Replies)
Discussion started by: machomaddy
5 Replies

10. Shell Programming and Scripting

With script bash, read file line per line starting at the end

Hello, I'm works on Ubuntu server My goal : I would like to read file line per line, but i want to started at the end of file. Currently, I use instructions : while read line; do COMMAND done < /var/log/apache2/access.log But, the first line, i don't want this. The file is long... (5 Replies)
Discussion started by: Fuziion
5 Replies
getitems(1F)							   FMLI Commands						      getitems(1F)

NAME
getitems - returns a list of currently marked menu items SYNOPSIS
getitems [delimiter_string] DESCRIPTION
The getitems function returns the value of lininfo if defined, else it returns the value of the name descriptor, for all currently marked menu items. Each value in the list is delimited by delimiter_string. The default value of delimiter_string is newline. EXAMPLES
Example 1: A sample output of getitems command. The done descriptor in the following menu definition file executes getitems when the user presses ENTER (note that the menu is multise- lect): Menu="Example" multiselect=TRUE done=`getitems ":" | message` name="Item 1" action=`message "You selected item 1"` name="Item 2" lininfo="This is item 2" action=`message "You selected item 2"` name="Item 3" action=`message "You selected item 3"` If a user marked all three items in this menu, pressing ENTER would cause the following string to be displayed on the message line: Item 1:This is item 2:Item 3 NOTES
Because lininfo is defined for the second menu item, its value is displayed instead of the value of the name descriptor. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWcsu | +-----------------------------+-----------------------------+ SEE ALSO
attributes(5) SunOS 5.10 5 Jul 1990 getitems(1F)
All times are GMT -4. The time now is 12:53 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy