Sponsored Content
Top Forums Shell Programming and Scripting cutting long text by special char around 100 byte and newline Post 302579845 by Shawn, Lee on Tuesday 6th of December 2011 09:16:51 PM
Old 12-06-2011
cutting long text by special char around 100 byte and newline

Regard,

How can i cut the text by special char(|) around 100 byte
and write the other of the text at newline using Perl.

2|01|2059140001|34232883774|504106542|2733|2127292||55197897292|||||177011612201|87829918247|2011112 7|0|0|0|295438|251|573|0|0|0|0|0|0|0|0|0|0|0|54630|45890|93609|0|0|0|295330|0|0|||0

Thanks.

Last edited by Shawn, Lee; 12-07-2011 at 12:03 AM..
 

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
magic(5)							File Formats Manual							  magic(5)

Name
       magic - magic file for the file command

Syntax
       /usr/lib/file/magic

Description
       The  magic file is used by the command to identify files that have some sort of magic number.  A magic number is any numeric or string con-
       stant that identifies the file containing the constant.

       The file is formatted as follows:

       Byte offset
	    The byte offset is where information is found in the file. This is the number of bytes from the beginning of the  file  to	the  first
	    byte of the magic number or string. This may, optionally,  be preceded by a right angle bracket (>) to indicate a continuation line to
	    supply extra information in the printed message.

       Value type
	    The value type is the type of the information to be found at the specified byte offset.  The file data is interpreted as the following
	    valid types:

		 byte	  Unsigned char type
		 short	  Unsigned short type
		 long	  Long type
		 string   Character (byte) string

       Optional operator
	    Describes  how  the  value	specified  here should be compared with the data at the desired offset.  Valid operator characters are: an
	    equal sign, a right angle bracket, and a left angle bracket (=, >, <).  If none is specified, = is assumed.

       Value
	    The value to match. Numeric values may be decimal, octal, or hexadecimal.  String values are defined as regular expressions here.  The
	    regular expressions used here are extended in two ways from regular expression definition in ed(1).

		 1.  Normally  unprintable characters may be escaped with a backslash ().  The special characters 
, , 
, and f are allowed.
		     An octal representation can also be used to insert any desired byte value, except 0.   Normally,  regular	expression  cannot
		     handle  such  character  values.	Because the backslash is used as an escape character while the regular expression is being
		     read in, normal occurrences of a backslash in a regular expression must be escaped with a second backslash. As an example, (
		     must be written as \( and . must be written as \.

		 2.  Text  found  in  a file can also be inserted in the printed string with the use of the \% delimiter.  All text found between
		     these delimiters is substituted into the print string.

		     This regular expression search never terminates until a match is explicitly found or rejected.  The special character 
 is a
		     valid character in the patterns.  Therefore, the pattern .*  should never be used here.

       major, minor type
	    The major and minor file type numbers are not used by the command.

       String to print
	    Any  desired  text string.	Data from the file can be included with the use of continuation lines beginning with a right angle bracket
	    (>).  Two types of continuation lines are possible, depending on the sign of the byte offset entry.

	    If the byte offset is positive, the specified data can be printed in the string when requested with an appropriate format.

	    If the offset is a negative number, an internal routine will be called to test if a particular string is  necessary  and,  if  so,	to
	    return it.

	    The  byte  offset number is an index to an internal table of routines available for use. Two such routines are currently defined, both
	    for a.out images:

	    Byte Offset    Returned String(s)

	    -1: 	   ["old version 7 style symbol table"]
	    -2: 	   ["setuid "]["setgid "]["sticky "]

Examples
       The following is an example of a script.  The second line adds setuid, setgid text, if appropriate:
       0   string ^#![ ]*\%[^ 0*\%  7,4   %s
       >-2 long   0			7,4   %sscript
       The following is an example of an executable image:
       >-1 long   0		  12,3	 %s
       0   short  0413		  12,4	 demand paged pure
       >2  short  02		  12,4	 POSIX
       >2  short  01		  12,4	 SVID
       >-2 long   0		  12,4	 %sexecutable
       >16 long   >0		  12,4	 not stripped
       The following is an example of a text file:
       0   string ^ 1h[0-9][0-9][0-9][0-9][0-9]  7,1  sccsfile

Files
See Also
       file(1)

																	  magic(5)
All times are GMT -4. The time now is 09:06 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy