Sponsored Content
Top Forums Shell Programming and Scripting Cut output to same byte position Post 302097213 by HealthyGuy on Wednesday 22nd of November 2006 09:03:52 AM
Old 11-22-2006
Thanks everyone.

my samples are simplified so what I actually have are lines 300 bytes long.

I need to print bytes 1-3, 203-240, and 260-289, with blank spaces between so the output remains in the same position. This presents a problem with sed because putting 200 spaces in the replace segment doesn't make sense. The suggestions above are fine for my samples which are 10-12 bytes long but not for 300 byte long lines where are only need to print a few bytes across the line.

Interesting issue I have here I never thought would be so tricky to figure out when I started Smilie

Thanks for all suggestions
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

byte count and cut command

1. Is there a way to count the number of bytes of a variable? example: abc@yahoo.com is 13 bytes 2. Cut command only allows one byte for delimiter example: cut -f1 -d'.' delimited by period. Is there a way to have two or more characters in the delimiter field? thanks in adavance. :) (4 Replies)
Discussion started by: hemangjani
4 Replies

2. Shell Programming and Scripting

Cut position as a variable

Hi All, I wish to cut an input by using the below command but i would want to have the cut position as a variable. For eg, the position number is 11 now and i wish that this number is being assigned to a variable before putting into the cut function. Can this be done ? Can any expert help?... (1 Reply)
Discussion started by: Raynon
1 Replies

3. Shell Programming and Scripting

Check if 2 files are identical byte-to-byte?

In my server migration requirement, I need to compare if one file on old server is exactly the same as the corresponding file on the new server. For diff and comm, the inputs need to be sorted. But I do not want to disturb the content of the file and need to find byte-to-byte match. Please... (4 Replies)
Discussion started by: krishmaths
4 Replies

4. Shell Programming and Scripting

Remove a byte(Last byte from the last line)

Hi All Can anyone please suggest me how to remove the last byte from a falt file .This is from the last line's last BYTE. Please suggest me something. Thank's and regards Vinay (1 Reply)
Discussion started by: vinayrao
1 Replies

5. Shell Programming and Scripting

Perl- Output file is always 0 byte

Hi all, I am new to perl programming. However i have a script that connects to the database and spools that into an output file. Strange thing is that sometimes this script works and sometimes the ouput spool file is always 0 byte. I have verified the sql query and the query always returns... (5 Replies)
Discussion started by: amit1_x
5 Replies

6. Shell Programming and Scripting

Cut multiple data based on character position

How to extract multiple data based on character position. I need to fetch from 7-9 and 22-26 and there is no delimiter for 22-26 since it is part of the column. The file may have more than 1000 character long.I managed to pull any one but not both for example test data 12345 zxc vbnmlk... (1 Reply)
Discussion started by: zooby
1 Replies

7. Shell Programming and Scripting

How to cut line from certain position?

Hi Gurus, I want to cut my file from 27th charactor to the end of line. can anybody give some unix command to do this. Thanks in advance (3 Replies)
Discussion started by: ken6503
3 Replies

8. UNIX for Beginners Questions & Answers

Cut two individual position and summ

Hi All, I am having a huge file file. I need to cut the below column and do the below calculation I did the below command and able to do on full databased no on the individual based any help on doing each row by row cut -c 52-56 myfile | awk '{total = total + $1}END{print total}'... (7 Replies)
Discussion started by: arunkumar_mca
7 Replies

9. UNIX for Beginners Questions & Answers

Print byte position of extended ascii character

Hello, I am on AIX. When I encounter extended ascii characters and special characters on a file I need to print.. Byte position, actual character and line number. Is there a simple command that can give me the above result ? Thanks in advance (38 Replies)
Discussion started by: rosebud123
38 Replies

10. Shell Programming and Scripting

Cut command with dynamic passing of delimiter and position values

Hi All, We have a requirement of picking nth position value by using cut command. value would be delimited by any symbols. We have to pass delimited value and postition to get the value in a string. ex. echo "A,B,C,D,E" |cut -d "," -f3 echo "A|B|C|D|E"|cut -d "|" -f2 Kindly frame the... (5 Replies)
Discussion started by: KK230689
5 Replies
fold(1) 							   User Commands							   fold(1)

NAME
fold - filter for folding lines SYNOPSIS
fold [-bs] [-w width | -width] [file...] DESCRIPTION
The fold utility is a filter that will fold lines from its input files, breaking the lines to have a maximum of width column positions (or bytes, if the -b option is specified). Lines will be broken by the insertion of a NEWLINE character such that each output line (referred to later in this section as a segment) is the maximum width possible that does not exceed the specified number of column positions (or bytes). A line will not be broken in the middle of a character. The behavior is undefined if width is less than the number of columns any single character in the input would occupy. If the CARRIAGE-RETURN, BACKSPACE, or TAB characters are encountered in the input, and the -b option is not specified, they will be treated specially: BACKSPACE The current count of line width will be decremented by one, although the count never will become negative. fold will not insert a NEWLINE character immediately before or after any BACKSPACE character. CARRIAGE-RETURN The current count of line width will be set to 0. fold will not insert a NEWLINE character immediately before or after any CARRIAGE-RETURN character. TAB Each TAB character encountered will advance the column position pointer to the next tab stop. Tab stops will be at each column position n such that n modulo 8 equals 1. OPTIONS
The following options are supported: -b Counts width in bytes rather than column positions. -s If a segment of a line contains a blank character within the first width column positions (or bytes), breaks the line after the last such blank character meeting the width constraints. If there is no blank character meeting the requirements, the -s option will have no effect for that output segment of the input line. -w width|-width Specifies the maximum line length, in column positions (or bytes if -b is specified). If width is not a positive decimal number, an error is returned. The default value is 80. OPERANDS
The following operand is supported: file A path name of a text file to be folded. If no file operands are specified, the standard input will be used. EXAMPLES
Example 1: Submitting a file of possibly long lines to the line printer An example invocation that submits a file of possibly long lines to the line printer (under the assumption that the user knows the line width of the printer to be assigned by lp(1)): example% fold -w 132 bigfile | lp ENVIRONMENT VARIABLES
See environ(5) for descriptions of the following environment variables that affect the execution of fold: LANG, LC_ALL, LC_CTYPE, LC_MES- SAGES, and NLSPATH. EXIT STATUS
The following exit values are returned: 0 All input files were processed successfully. >0 An error occurred. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWcsu | +-----------------------------+-----------------------------+ |CSI |enabled | +-----------------------------+-----------------------------+ |Interface Stability |Standard | +-----------------------------+-----------------------------+ SEE ALSO
cut(1), pr(1), attributes(5), environ(5), standards(5) NOTES
fold and cut(1) can be used to create text files out of files with arbitrary line lengths. fold should be used when the contents of long lines need to be kept contiguous. cut should be used when the number of lines (or records) needs to remain constant. fold is frequently used to send text files to line printers that truncate, rather than fold, lines wider than the printer is able to print (usually 80 or 132 column positions). fold may not work correctly if underlining is present. SunOS 5.10 1 Feb 1995 fold(1)
All times are GMT -4. The time now is 11:14 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy