09-13-2012
If that string can contain arbitrary binary data, you may have problems. Many UNIX utilities (sed, awk, sh, etc ...) are designed to read text files. Text files are not expected to contain control characters and nullbytes. Nullbytes (\0) in particular could cause failure since UNIX text tools often rely on the c library's string handling functions, which use \0 as a terminator.
Regards,
Alister
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
input string="3MMTQSZ348GGMZRQWMJM4SD6M"
output string="3MMTQ-SZ348-GGMZR-QWMJM-4SD6M"
using linux shell script (4 Replies)
Discussion started by: pankajd
4 Replies
2. Shell Programming and Scripting
Hi people,
i have a nice problem to solve..
in an text page i must change all the "*.php" occourences to the respective lowercase..
Example:
...
<tr><td>
<form action="outputEstrazione.php" method="get">
<table cellspacing='0,5' bgcolor='#000000'><tr><td>
<font size='2'... (5 Replies)
Discussion started by: marconet85
5 Replies
3. Shell Programming and Scripting
i read the "cat" manpages,
but i could not find to tell it like
"read file XY.BIN from byte 1000 to byte 5000"
can somebody please point me into the right direction?
cat would be the ideal tool for my purpose, the way it behaves, but i miss this ranges option.
thanks for any input. (2 Replies)
Discussion started by: scarfake
2 Replies
4. Shell Programming and Scripting
Hello everyone
Sorry I have to add another sed question. I am searching a log file and need only the first 2 occurances of text which comes after (note the space) "string " and before a ",". I have tried
sed -n 's/.*string \(*\),.*/\1/p' filewith some, but limited success. This gives out all... (10 Replies)
Discussion started by: haggismn
10 Replies
5. Shell Programming and Scripting
logs:
"/home/abc/public_html/index.php"
"/home/abc/public_html/index.php"
"/home/xyz/public_html/index.php"
"/home/xyz/public_html/index.php"
"/home/xyz/public_html/index.php"
how to use "cut" or "awk" or "sed" to get the following result:
abc
abc
xyz
xyz
xyz (8 Replies)
Discussion started by: timmywong
8 Replies
6. Shell Programming and Scripting
I came across and unexpected behavior with redirections in tcsh. I know, csh is not best for redirections, but I'd like to understand what is happening here.
I have following script (called out_to_streams.csh):
#!/bin/tcsh -f
echo Redirected to STDOUT > /dev/stdout
echo Redirected to... (2 Replies)
Discussion started by: marcink
2 Replies
7. Shell Programming and Scripting
Hello.
Following recommendations for one of my threads, this is working perfectly :
#!/bin/bash
CNT=$( grep -c -e "some text 1" -e "some text 2" -e "some text 3" "/tmp/log_file.txt" )
Now I need a grep success for some thing like :
#!/bin/bash
CNT=$( grep -c -e "some text_1... (4 Replies)
Discussion started by: jcdole
4 Replies
8. UNIX for Dummies Questions & Answers
Hello,
I have a question regarding extracting parts of a string and the meaning of # and % in the syntax. I created an example below.
# filename=/first/second/third/fourth
#
# echo $filename
/first/second/third/fourth
#
# echo "${filename##*/}"
fourth
#
# echo "${filename%/*}"... (3 Replies)
Discussion started by: shah9250
3 Replies
9. Shell Programming and Scripting
Dear Ladies & Gents,
I have a requirement to delete all the log files in /var/log/test directory that are older than 10 days and their first line begin with "MSH" or "<?xml" or "FHS". I've put together the following BASH script, but it's erroring out:
for filename in $(find /var/log/test... (2 Replies)
Discussion started by: Hiroshi
2 Replies
10. Windows & DOS: Issues & Discussions
So, I have a folder, containing subdirs like this:
52334d50
52365245
524b4450
524f3350
52533950
52535050
52555550
now I want to go ahead and rename all those folder:
hex -> ascii (8 Replies)
Discussion started by: pasc
8 Replies
LEARN ABOUT OSF1
xmtextgetsubstring
XmTextGetSubstring(3X) XmTextGetSubstring(3X)
NAME
XmTextGetSubstring - A Text function that retrieves a copy of a portion of the internal text buffer
SYNOPSIS
#include <Xm/Text.h>
int XmTextGetSubstring (widget, start, num_chars, buffer_size, buffer)
Widget widget;
XmTextPosition start;
int num_chars;
int buffer_size;
char *buffer;
DESCRIPTION
XmTextGetSubstring retrieves a copy of a portion of the internal text buffer of a Text widget. The function copies a specified number of
characters from a given start position in the internal text buffer into a buffer provided by the application. A NULL terminator is placed
at the end of the copied data.
The size of the required buffer depends on the maximum number of bytes per character (MB_CUR_MAX) for the current locale. MB_CUR_MAX is a
macro defined in <stdlib.h>. The buffer should be large enough to contain the substring to be copied and a NULL terminator. Use the fol-
lowing equation to calculate the size of buffer the application should provide:
buffer_size = (num_chars * MB_CUR_MAX) + 1 Specifies the Text widget ID. Specifies the beginning character position from which the data
will be retrieved. This is an integer number of characters from the beginning of the text buffer. The first character position is 0.
Specifies the number of characters to be copied into the provided buffer. Specifies the size of the supplied buffer in bytes. This size
should account for a NULL terminator. Specifies the character buffer into which the internal text buffer will be copied.
For a complete definition of Text and its associated resources, see XmText(3X).
RETURN VALUE
The function was successful. The function failed because it was unable to copy the specified number of characters into the buffer pro-
vided. The buffer size may be insufficient. The contents of buffer are undefined. The requested number of characters extended beyond the
internal buffer. The function copied characters between start and the end of the widget's buffer and terminated the string with a NULL
terminator; fewer than num_chars characters were copied.
SEE ALSO
XmText(3X), XmTextGetSubstringWcs(3X)
XmTextGetSubstring(3X)