Sponsored Content
Top Forums Shell Programming and Scripting cutting long text by special char around 100 byte and newline Post 302579857 by ahamed101 on Tuesday 6th of December 2011 10:58:57 PM
Old 12-06-2011
Try this...
Code:
awk -F'|' '{for(i=1;i<=NF;i++){s+=length($i)+1;if(s<=100){printf $i OFS}else{print $i OFS;s=0}}printf"\n"}' 
OFS='|' input_file

--ahamed

Last edited by ahamed101; 12-07-2011 at 05:12 AM..
This User Gave Thanks to ahamed101 For This Post:
 

10 More Discussions You Might Find Interesting

1. Debian

Serial printer cutting last page of long reports...

Any ideas what could cause this? I have flow control set to XON XOFF on the printer and the on the OS level. (1 Reply)
Discussion started by: djsal
1 Replies

2. UNIX for Advanced & Expert Users

Using egrep to search for Text and special char

Anyone is well-versed to use egrep to search a file for a line containing both: 1) AAA 2) $ I am having problem escaping the dollar sign when using egrep in conjunction with satisfying AAA as well. E.g. Text file Line 1 AAA Line 2 $$$ Line 3 AAA BBB $ Line 4 $$$ BBB AA will return me... (2 Replies)
Discussion started by: izy100
2 Replies

3. Shell Programming and Scripting

How to replace any char with newline char.

Hi, How to replace any character in a file with a newline character using sed .. Ex: To replace ',' with newline Input: abcd,efgh,ijkl,mnop Output: abcd efgh ijkl mnop Thnx in advance. Regards, Sasidhar (5 Replies)
Discussion started by: mightysam
5 Replies

4. Shell Programming and Scripting

Splitting a variable based on newline char

Heeloo all, A weird problem perhaps. May god save others from this problem. I want to print each line from a variable.. the example below should make it clear. smvar="Hello World1 Hello world 2 forgot there I guess" for eachline in $smvar echo $eachline end Whats for... (3 Replies)
Discussion started by: pavanlimo
3 Replies

5. Shell Programming and Scripting

Help substituting text in a file having a single line but no newline char

Hello, Need help substituting a particular word in a file having a single line but no newline character at the end. I was trying to use sed but it doesn't work probably because there is no newline char at the end of the line. $ cat hlq_detail /outputs/alvan23/PDFs/bills $ cat... (5 Replies)
Discussion started by: Shan_u2005
5 Replies

6. UNIX for Dummies Questions & Answers

Remove a newline char from selected rows.

Greetings! Can we automate the process of removing a newline char from selected rows in a fixed width file using a shell? Input is like abcd1234 xyzd1234 abcd a1b2c3d4 abcd1234 xyzd1234 xx abcd1234 Expected output - abcd1234xyzd1234 abcda1b2c3d4abcd1234xyzd1234 xxabcd1234 ... (2 Replies)
Discussion started by: mailme0205
2 Replies

7. UNIX for Dummies Questions & Answers

Remove newline char from variable

I have a file ABC.DAT with 2 columns avaialble Data format : XYZ!$#$!120 XXZ!$#$!1000 YYZ!$#$!104 While running the following code : FILE_COUNTER=1; RECORD_CN_FILE_COUNT=$((`wc -l ABC.DAT| cut -f1 -d' '`)); while do FILE_NAME=`cat ABC.DAT.DAT| head -$FILE_COUNTER |tail -1 | awk -F... (1 Reply)
Discussion started by: Nikhil Gautam
1 Replies

8. UNIX for Dummies Questions & Answers

Changing a special line and Byte in a random file

Hello I created 3 files by: dd if=/dev/urandom bs=1024 count=1000000 of=./testfile1 dd if=/dev/urandom bs=1024 count=5000000 of=./testfile2 dd if=/dev/urandom bs=1024 count=10000000 of=./testfile3 Now I want to know how to make a change in a specific byte and/or line of theses files? (2 Replies)
Discussion started by: frhling
2 Replies

9. Shell Programming and Scripting

Replace Special Character With Next Present Byte

Hi, First find the special character, from the special character take next two bytes convert the bytes to decimal and replace with next present byte of decimal value times. E.g. Input: 302619ú1A? Output: 302619(3 spaces for ú1A)?????????????????????????? Thanks, Dines (27 Replies)
Discussion started by: dineshnak
27 Replies

10. Shell Programming and Scripting

Char/byte positions of delimiters in file

I have a pipe delimited file and I'm trying to write a script that will give the character/byte positions of each pipe in the file. There may be some simple way but I don't know what it is... Can someone help with this? Ex: file has output below abc|def|ghi| I want the script to tell the... (1 Reply)
Discussion started by: basz808
1 Replies
XStoreBytes(3X11)						     MIT X11R4							 XStoreBytes(3X11)

Name
       XStoreBytes, XStoreBuffer, XFetchBytes, XFetchBuffer, XRotateBuffers - manipulate cut and paste buffers

Syntax
       XStoreBytes(display, bytes, nbytes)
	  Display *display;
	  char *bytes;
	  int nbytes;

       XStoreBuffer(display, bytes, nbytes, buffer)
	  Display *display;
	  char *bytes;
	  int nbytes;
	  int buffer;

       char *XFetchBytes(display, nbytes_return)
	  Display *display;
	  int *nbytes_return;

       char *XFetchBuffer(display, nbytes_return, buffer)
	  Display *display;
	  int *nbytes_return;
	  int buffer;

       XRotateBuffers(display, rotate)
	  Display *display;
	  int rotate;

Arguments
       buffer	 Specifies the buffer in which you want to store the bytes or from which you want the stored data returned.

       bytes	 Specifies the bytes, which are not necessarily ASCII or null-terminated.

       display	 Specifies the connection to the X server.

       nbytes	 Specifies the number of bytes to be stored.

       nbytes_return
		 Returns the number of bytes in the buffer.

       rotate	 Specifies how much to rotate the cut buffers.

Description
       Note that the cut buffer's contents need not be text, so zero bytes are not special.  The cut buffer's contents can be retrieved later by
       any client calling

       can generate a error.

       If the property for the buffer has never been created, a error results.

       can generate and errors.

       The function returns the number of bytes in the nbytes_return argument, if the buffer contains data.  Otherwise, the function returns NULL
       and sets nbytes to 0.  The appropriate amount of storage is allocated and the pointer returned.	The client must free this storage when
       finished with it by calling Note that the cut buffer does not necessarily contain text, so it may contain embedded zero bytes and may not
       terminate with a null byte.

       The function returns zero to the nbytes_return argument if there is no data in the buffer.

       can generate a error.

       The function rotates the cut buffers, such that buffer 0 becomes buffer n, buffer 1 becomes n + 1 mod 8, and so on.  This cut buffer num-
       bering is global to the display.  Note that generates errors if any of the eight buffers have not been created.

       can generate a error.

Diagnostics
       The server failed to allocate the requested resource or server memory.

       A value for an Atom argument does not name a defined Atom.

       Some argument or pair of arguments has the correct type and range but fails
		 to match in some other way required by the request.

       Some numeric value falls outside the range of values accepted by the request.
		 Unless a specific range is specified for an argument, the full range defined by the argument's type is accepted. Any argument
		 defined as a set of alternatives can generate this error.

See Also
       XFree(3X11)
       X Window System: The Complete Reference, Second Edition, Robert W. Scheifler and James Gettys

																 XStoreBytes(3X11)
All times are GMT -4. The time now is 05:40 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy