Sponsored Content
Top Forums Shell Programming and Scripting Seperated a Column from 'ESC' Character seperated file Post 303020426 by wisecracker on Thursday 19th of July 2018 08:31:24 AM
Old 07-19-2018
Quote:
Originally Posted by neha_suri06
Hi Experts

I have an escape seperated fields in the unix file. And in the below format file I need to extract the first column. Please help its urgent.

Code:
cat -v op.dat | head

24397028^[ABCD1234^[ABCD1234^[ ^[May 24 2011 12:10PM^[^[^[CSGBU
2439707^[ABCD1234^[ABCD1234^[ ^[Oct 25 2011  9:42AM^[^[^[CSGBU

I want to extract the file in below format ( with only first column )

Code:
24397028
2439707

OSX 10.13.5, default bash terminal.

Code:
Last login: Thu Jul 19 13:26:35 on ttys000
AMIGA:amiga~> echo '24397028^[ABCD1234^[ABCD1234^[ ^[May 24 2011 12:10PM^[^[^[CSGBU
> 2439707^[ABCD1234^[ABCD1234^[ ^[Oct 25 2011  9:42AM^[^[^[CSGBU' > /tmp/escape
AMIGA:amiga~> hexdump -C /tmp/escape
00000000  32 34 33 39 37 30 32 38  5e 5b 41 42 43 44 31 32  |24397028^[ABCD12|
00000010  33 34 5e 5b 41 42 43 44  31 32 33 34 5e 5b 20 5e  |34^[ABCD1234^[ ^|
00000020  5b 4d 61 79 20 32 34 20  32 30 31 31 20 31 32 3a  |[May 24 2011 12:|
00000030  31 30 50 4d 5e 5b 5e 5b  5e 5b 43 53 47 42 55 0a  |10PM^[^[^[CSGBU.|
00000040  32 34 33 39 37 30 37 5e  5b 41 42 43 44 31 32 33  |2439707^[ABCD123|
00000050  34 5e 5b 41 42 43 44 31  32 33 34 5e 5b 20 5e 5b  |4^[ABCD1234^[ ^[|
00000060  4f 63 74 20 32 35 20 32  30 31 31 20 20 39 3a 34  |Oct 25 2011  9:4|
00000070  32 41 4d 5e 5b 5e 5b 5e  5b 43 53 47 42 55 0a     |2AM^[^[^[CSGBU.|
0000007f
AMIGA:amiga~> _

There is no escape character, there are however a carat with a left hand square bracket representing an escape - so is it a real escape character [0x]1B you need to be detected or is the carat good enough?
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Search and then concat 4m other file (comma seperated)

My query is now a bit simplified. file1.txt names; ID; value1 ; values N; ABC; 1 ; a18 ; ... CDF; 2 ; b16 ; .. ABC; 1 ; c13 ; ...... EFG; 3 ;d12 ; ... file2.txt ID(Unique);smVals; smVal1; smVal N; 1; ...; ...; ...; 2; ..; ..; ..; 3; ..; ..; ..; ... (1 Reply)
Discussion started by: szchmaltz
1 Replies

2. UNIX for Dummies Questions & Answers

Problem with tab seperated file in UNIX

Hi All, I am facing a problem while getting the data from an Oracle table Problem: I am getting rows from an Oracle table to a tab seperated file. One of the columns in that table have value with in between spaces like AAAAA AAA It's loading fine to .tab file. But when... (2 Replies)
Discussion started by: pssandeep
2 Replies

3. Shell Programming and Scripting

Removing blank lines from comma seperated and space seperated file.

Hi, I want to remove empty/blank lines from comma seperated and space seperated files Thanks all for help (11 Replies)
Discussion started by: pinnacle
11 Replies

4. Shell Programming and Scripting

Trimming fields for comma or pipe seperated file

I have file like this FileA: abc , "helloworld" , america def,asia, japan ghi, africa, ipl Output Needed: abc,"helloworld",america def,asia,japan ghi,africa,ipl I would like to implement using awk. I want to trim each field for its leading and trailing spaces. (7 Replies)
Discussion started by: pinnacle
7 Replies

5. Shell Programming and Scripting

Convert comma seperated file to line seperated.

Hi, I have data like this. 1,2,3,4 Output required: 1 2 3 4 I am trying to use tr function but getting error. Help is appreciated. (6 Replies)
Discussion started by: pinnacle
6 Replies

6. UNIX for Advanced & Expert Users

grep 7th column from a file seperated with ^

Hi, Can anyone help: I want to get the 7th column of a file seperated by ^ Num:^ 1^ testdevice1^10.1.1.1^PT1X23^true^HD^175^up^false^bad Num:^ 2^ testdevice2^10.1.1.2^ST1X23^true^SN^175^up^false^bad Expected result: HD SN Appreciate your help. (2 Replies)
Discussion started by: sureshcisco
2 Replies

7. UNIX for Dummies Questions & Answers

Need help removing leading spaces from one field in comma seperated file

Using awk or sed, I'd like to remove leading spaces after a comma and before a right justified number in field 6. Sounds simple but I can't find a solution. Each field's formatting must stay intact. Input: 40,123456-02,160,05/24/2012,02/13/1977, 10699.15,0 Output:... (5 Replies)
Discussion started by: Scottie1954
5 Replies

8. Shell Programming and Scripting

Seperated by columns, merge in a file, sort them on common column

Hi All, I have 4 files in below format. I took them as an example. File 1: Cut from position 1-4 then 6-7 then 8-14 then rest left and make them as columns in one new file. Inserting character H to the initial of all line like HCTOT. CTOT 456787897 Low fever CTOR 556712345 High fever... (2 Replies)
Discussion started by: Mannu2525
2 Replies

9. Shell Programming and Scripting

SUM semicolon-seperated values from txt-file

Hello, (I'm a shell beginner) how can I sum the bold values of the following txt-file (values.txt) with bash shell. The result of the sum should be written in a new txt file (sum.txt): ... Thanks in advance (5 Replies)
Discussion started by: milu
5 Replies

10. Shell Programming and Scripting

Need Help in rearranging the content of a file comma seperated

I have a file with the below content a = test1 b = test2 a = test3 b= test4 c = test6 b = test5 d = test7 d = test9 Need the output to be as follows a = test1,test3 b = test2, test5 c = test6 d = test7, test9 (4 Replies)
Discussion started by: iron_michael86
4 Replies
IMAGE_TO_J2K(1) 						  OPENJPEG TOOLS						   IMAGE_TO_J2K(1)

NAME
image_to_j2k - convert a PNM, PGM, PPM, PGX or BMP into a J2K or JP2 file SYNOPSIS
DESCRIPTION
image_to_j2k converts an image into a JPEG 2000-encoded image OPTIONS
-ImgDir sourcedir Directory of PGM, PPM, PNM, PGX or BMP files to convert -OutFor extension J2K or JP2 output file format -i source PNM, PGM or PPM file to convert -o destination J2K or JP2 file to output to -h Display help information -cinema2k fps Digital Cinema 2K profile compliant codestream for 2K resolution. 24 or 48 fps. -cinema4k [fps] Digital Cinema 4K profile compliant codestream for 4K resolution. fps default is 24 -r ratios compression factor for successive layers, comma seperated -q psnr psnr for successive layers, comma seperated -n rescount number of resolutions -b blocksize width and height of code block, comma-seperated -c precintsize width and height of precinct, comma-seperated -t tilesize width and height of tile, comma-seperated -p progression progression order, one of LRCP, RLCP, RPCL, PCRL, CPRL -s subsampling subsampling factor in X and Y, comma-seperated. Values larger than 2 can produce errors -POC orders progression order change -SOP write SOP marker before each packet -EPH write EPH marker after each header packet -M modeflags Sum of the values of the modes, as follows: 1. BYPASS (LAZY) 2. RESET 4. RESTART (TERMALL) 8. VSC 16. ERTERM (SEGTERM) 32. SEGMARK (SEGSYM) -x indexfile create an index file -ROI:quantize quantization indices upshifted for component c between 0 and 2 inclusive with an upshift of U between 0 and 37 inclusive -d imageoffset X and Y offset of the origin of the image, comma-seperated -T tileoffset X and Y offset of the origin of the tiles, comma-seperated -I use the irreversible DWT 9-7 EXAMPLE
ratios: 20,10,1 Quality 1: compress 20x; Quality 2: compress 10x; Quality 3: lossless compression psnr: 30,40,50 quantize: c=0,U=25 orders: T1=0,0,1,5,3,CPRL Title 1: Resolution 0 start, component 0 start, layer 1 end, resolution 5 end, component 3 end, CPRL progression AUTHOR
Written by Paul Hampson <Paul.Hampson@Pobox.com> based on the output of image_to_j2k -h as part of the Debian packaging of OpenJPEG COPYRIGHT
Copyright 2007 Paul Hampson SEE ALSO
j2k_to_image(1), <http://www.openjpeg.org/index.php?menu=doc#encoder> 1.3+dfsg 2014-04-22 IMAGE_TO_J2K(1)
All times are GMT -4. The time now is 09:04 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy