12-13-2007
Thanks Porter. I have calculated the offset from where I have to read. I believe before using lseek, I will have to open the file using open system call. I am getting a syntax error when I try to open the file. Please see code below:
apdma001:/amex/home/mqm/.saurabh # vi Myprog
"Myprog" 30 lines, 924 characters
# This is my first program
USAGE="Myprog <profile to be searched> "
if [ $# -ne 1 ]
then
echo "Invalid number of arguements :USAGE : $USAGE "
exit
fi
strToSearch="\."$1
# Write all relevant profiles into Myprog1. Filter those lines which have "MQQUEUE" so that only one occurance is listed
grep $strToSearch Sarah.txt | grep -v MQQUEUE > Myprog1
echo "Following profiles have been found:"
myfile="/amex/home/mqm/.saurabh/Myprog1"
myline=""
fd=open("Sarah.txt",O_RDONLY)
while [ 1 ]
do
read myline || break
# Remove "(G)" from the profile name
set -A profileNm $myline
# Search for second occurance of profileNm and read the line number of the second occurance
grep -n $profileNm Sarah.txt | head -n 2 | tail -n 1 | cut -f1 -d ":" | read startline
# Increase offset by 57 to move to access area
startline=`expr $startline + 57`
echo "$profileNm : $startline"
done < $myfile
Myprog[18]: 0403-057 Syntax error at line 18 : `(' is not expected.
I am new to unix, so my questions may appear very silly. But I am just trying to learn. Appreciate your help.
Thanks,
Saurabh
10 More Discussions You Might Find Interesting
1. UNIX for Advanced & Expert Users
Hi All,
I need to extract only XML details from large log file which may contain other unwanted junk details.
For example, our xml will be start as <OUTBOUND_MESSAGE .....> and ends with </OUTBOUND_MESSAGE>. I want to extract only lines between these start and end tag (Including these tags)... (5 Replies)
Discussion started by: thinakarmani
5 Replies
2. Programming
Function: int fcntl(int fd, int cmd, struct flock * lock)
Data Type: struct flock
This structure is used with the fcntl function to describe a file lock. It has these members:
off_t l_start
This specifies the offset of the start of the region to which the lock applies, and... (1 Reply)
Discussion started by: DNAx86
1 Replies
3. Shell Programming and Scripting
I have a lot of very large hex files that I need to change one value at the same offset and save to another file. I have a script that finds each file and just need to put an operator for each file.
I think sed might be able to do this but I have not used it before and would like some help. If... (8 Replies)
Discussion started by: Eruditass
8 Replies
4. Solaris
root@erpqas# vxdg -g sap_dg free
DISK DEVICE TAG OFFSET LENGTH FLAGS
sapdisk3 c1t10d0s2 c1t10d0 15707513 2869 -
sapdisk3 c1t10d0s2 c1t10d0 71080956 43335 -
sapdisk5 c1t12d0s2 c1t12d0 70321149 803142 -
... (1 Reply)
Discussion started by: tv.praveenkumar
1 Replies
5. Shell Programming and Scripting
Hi,
I'm looking for a way (other than C) to pull out a number of bytes in a Linux file for a giving length. for example:
file1 contains 2 records:
abcdefghijkl
mnopqrstuv
.....
so, I want to pull starting in byte 9 for a length of 8
file2 would contain:
ijkmnopq
Thanks (2 Replies)
Discussion started by: jbt828
2 Replies
6. Solaris
How to add offset to NTP client so that, for eg., clock is -20 seconds? (2 Replies)
Discussion started by: orange47
2 Replies
7. UNIX for Dummies Questions & Answers
I have read the below from the book bash cookbook.Tail +1 filenames is similar to cat filename
I have tried the same in Ubuntu 11.10 with bash. 4.0 .
I have received error for the Same.
May I know in which system that will work fine ?
Thanks (1 Reply)
Discussion started by: pandeesh
1 Replies
8. Shell Programming and Scripting
Hi ,
I have a .gz file whose contents look like below.
data1^filename1
data2^filename2.
..
.
.
Is it possible to find out the byte offset of each record from the .gz file.
Like in an uncompressed file.
grep -nb "Filename" give the byte offset of the record in this case.
... (4 Replies)
Discussion started by: chetan.c
4 Replies
9. UNIX for Advanced & Expert Users
Hi,
I am trying to get the position of a repeated string in a line using
grep -b -o "pattern"
In my server I am using GNU grep version 2.14 and the code is working fine. However when I am deploying the same code in a different server which is using GNU grep version 2.5.1 the code is not... (3 Replies)
Discussion started by: Subhamoy
3 Replies
10. UNIX for Dummies Questions & Answers
Dear all,
I want to offset the file numbers. can you please make some awk code or linux code for the same.
Example:
input file names
ANI_WFMASS_PIST00001.gif
ANI_WFMASS_PIST00002.gif
.
.
.
ANI_WFMASS_PIST0000n.gif
offset --> 30
ANI_WFMASS_PIST00031.gif
ANI_WFMASS_PIST00032.gif... (14 Replies)
Discussion started by: kri321shna
14 Replies
LEARN ABOUT CENTOS
grub-render-label
GRUB-RENDER-LABEL(1) User Commands GRUB-RENDER-LABEL(1)
NAME
grub-render-label - generate a .disk_label for Apple Macs.
SYNOPSIS
grub-render-label [OPTION...] [OPTIONS]
DESCRIPTION
Render Apple .disk_label.
-b, --bgcolor=COLOR
use COLOR for background
-c, --color=COLOR
use COLOR for text
-f, --font=FILE
use FILE as font (PF2).
-i, --input=FILE
read text from FILE.
-o, --output=FILE
set output filename. Default is STDOUT
-t, --text=STRING
set the label to render
-v, --verbose
print verbose messages.
-?, --help
give this help list
--usage
give a short usage message
-V, --version
print program version
Mandatory or optional arguments to long options are also mandatory or optional for any corresponding short options.
REPORTING BUGS
Report bugs to <bug-grub@gnu.org>.
SEE ALSO
The full documentation for grub-render-label is maintained as a Texinfo manual. If the info and grub-render-label programs are properly
installed at your site, the command
info grub-render-label
should give you access to the complete manual.
grub-render-label (GRUB) 2.02-2ubuntu8.3 July 2018 GRUB-RENDER-LABEL(1)