Sponsored Content
Top Forums Shell Programming and Scripting Cut output to same byte position Post 302097192 by HealthyGuy on Wednesday 22nd of November 2006 07:50:37 AM
Old 11-22-2006
Hi Manish

This does print the correct positions but does not fill in the spaces between with the same number of bytes turned to blanks that were in the original. For example, if we take the following 2 lines.

ABC123DEF
GEH456JKL
Say I want to print position 1-2 and 6-8 and want everything in between turned to blank spaces so the byte positions from my input are in the same positions as my output.

Say x is a blank space the output should look like:
ABxxx3DEx
GExxx6JKx

The suggested awk with substr gives me the right substrings but in the wrong position in the new file:
AB3DE
GE6JK

Thanks for any 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
expand(1)							   User Commands							 expand(1)

NAME
expand, unexpand - expand TAB characters to SPACE characters, and vice versa SYNOPSIS
expand [-t tablist] [file...] expand [-tabstop] [ -tab1, tab2,. . ., tabn] [file...] unexpand [-a] [-t tablist] [file...] DESCRIPTION
The expand utility copies files (or the standard input) to the standard output, with TAB characters expanded to SPACE characters. BACKSPACE characters are preserved into the output and decrement the column count for TAB calculations. expand is useful for pre-processing character files (before sorting, looking at specific columns, and so forth) that contain TAB characters. unexpand copies files (or the standard input) to the standard output, putting TAB characters back into the data. By default, only leading SPACE and TAB characters are converted to strings of tabs, but this can be overridden by the -a option (see the OPTIONS section below). OPTIONS
The following options are supported for expand: -t tablist Specifies the tab stops. The argument tablist must consist of a single positive decimal integer or multiple posi- tive decimal integers, separated by blank characters or commas, in ascending order. If a single number is given, tabs will be set tablist column positions apart instead of the default 8. If multiple numbers are given, the tabs will be set at those specific column positions. Each tab-stop position N must be an integer value greater than zero, and the list must be in strictly ascending order. This is taken to mean that, from the start of a line of output, tabbing to position N causes the next char- acter output to be in the (N+1)th column position on that line. In the event of expand having to process a tab character at a position beyond the last of those specified in a mul- tiple tab-stop list, the tab character is replaced by a single space character in the output. -tabstop Specifies as a single argument, sets TAB characters tabstop SPACE characters apart instead of the default 8. -tab1,tab2,...,tabn Sets TAB characters at the columns specified by -tab1,tab2,...,tabn The following options are supported for unexpand: -a Inserts TAB characters when replacing a run of two or more SPACE characters would produce a smaller output file. -t tablist Specifies the tab stops. The option-argument tablist must be a single argument consisting of a single positive decimal integer or multiple positive decimal integers, separated by blank characters or commas, in ascending order. If a single number is given, tabs will be set tablist column positions apart instead of the default 8. If multiple numbers are given, the tabs will be set at those specific column positions. Each tab-stop position N must be an integer value greater than zero, and the list must be in strictly ascending order. This is taken to mean that, from the start of a line of output, tabbing to position N will cause the next character output to be in the (N+1)th column position on that line. When the -t option is not specified, the default is the equivalent of specifying -t 8 (except for the interaction with -a, described below). No space-to-tab character conversions occur for characters at positions beyond the last of those specified in a multiple tab-stop list. When -t is specified, the presence or absence of the -a option is ignored; conversion will not be limited to the processing of leading blank characters. OPERANDS
The following ooperand is supported for expand and unexpand: file The path name of a text file to be used as input. ENVIRONMENT VARIABLES
See environ(5) for descriptions of the following environment variables that affect the execution of expand and unexpand: LANG, LC_ALL, LC_CTYPE, LC_MESSAGES, and NLSPATH. EXIT STATUS
The following exit values are returned: 0 Successful completion >0 An error occurred. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWesu | +-----------------------------+-----------------------------+ |CSI |enabled | +-----------------------------+-----------------------------+ |Interface Stability |Standard | +-----------------------------+-----------------------------+ SEE ALSO
tabs(1), attributes(5), environ(5), standards(5) SunOS 5.10 1 Feb 1995 expand(1)
All times are GMT -4. The time now is 08:37 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy