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.
I want to extract the file in below format ( with only first column )
OSX 10.13.5, default bash terminal.
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?
The ^[ is (not only) cat -v 's way to represent the ESC- char. Caret won't be good enough, won't work.
Let's wait for the requestor's attempts before we post valid solutions.
Hi neha_suri06,
If you want quick replies to your queries, and have those replies have a good chance of woking in your environment, it is crucial that you always tell us what operating system you're using, what shell you're using, and show us what you have tried.
Showing us the output from cat -v file gives us ambiguous data about what the actual contents are of the file named by file might be. If your sample input file has fields delimited by ASCII escape characters, we know that it contains at least two lines each containing somewhere between one and seven fields. To help us test code that might work to solve your problem, it is always better to include a copy of the data you want to process (in CODE tags) or upload a copy of the file itself. If there are questions about the data contained in a file, showing us the output from hexdump -C file (if it is available on your system) or od -bc file (which should be available on any UNIX or UNIX-like system) is always better than cat -v file because they both produce unambiguous output.
Refusing to answer questions about what you have tried and what you have considered trying makes it very clear that, despite what you said in your first post, this problem must not really be urgent for you.
Hi chandan.chaman and wisecracker,
As RudiC has already said, if you look closely at post #1 in this thread, you will see that the sample input show in that post is not the actual contents of the file named op.dat; it is the contents of op.dat after processing by cat -v. From that output, we don't know if there are any circumflex characters in op.dat, but we do know that if there are any, they are data rather than being field delimiters.
If we knew that there are no circumflex characters in the first field in op.dat (which is not stated anywhere in neha_suri06's requirements but might be assumed from the given example), one could try the grossly inefficient:
Much better solutions could be suggested if we knew what operating system and shell neha_suri06 is using and had a better understand of what neha_suri06 had already tried to solve this problem.
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)
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)
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)
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)
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)
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)
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)