How to cut a line that contains two different separator
Hi all,
I have a script that receives a file, receives the values and put them on an oracle database.
I need to do this for multiple files that will contain in the end near 500 million records, so performance is a major concern.
until now there was no issue because the file I'm receiving is a csv in the format:
but management decided to change to a diferent provider and this one is providing the files with the following output:
previously when i wanted to access a field, for example field 3 i just need to do:
I'm trying to get one expression that doesn't require regular expressions to get the same output with the new file but I'm unable to find a way do get this.
Is there any option I can indicate two separators to the cut expression?
Using this with both expressions I would get "value3".
In this case I would not require regular expression and just needed to ajust the indexes I use for the several fields...
I forgot to add something...
I've tried that and this is what i get:
but I need to get multiple values at once I'm not able to make it work.
Is it possible to configure cut to do that?
For example if I want to get "value1", "value2" and "value3" at once!
It works with AWK. but i would prefer to use cut because cut I know it can be integrated correctly in another tool I use and I'm not sure It as support for AWK.
with AWK:
Regards
---------- Post updated at 08:12 AM ---------- Previous update was at 07:49 AM ----------
Got a solution that works for me:
Thanks.
Last edited by naoseionome; 07-08-2011 at 12:52 PM..
Reason: added awk results
Unix File is pipe delimited with 17 fields. We may get extra pipes in data also.
We may get \n char (1 or more \n in one field or multi fileds) in data in any field.
Need to replace \n true ( line separator) with 'space and bell char space' chars (' \a ') Not data \n.
Input:... (1 Reply)
Hi Guys,
I have the file
---
HOST_NAME,data_coleta,data_carga,CPU_util,CPU_idle,run_queue,memory,MEMORY_SYSTEM,MEMORY_TOTAL,MEMORY_SWAPIN,MEMORY_SWAPOUT,DISK_READ,DISK_WRITE,DISK_IO,NET_IN_PACKET,
NET_OUT_PACKET... (4 Replies)
Hi All,
I have a file with 20 columns, and the data itself has "\n" new line in it. So we have changed the row delimiter to ^E.
Now i am unable to use head, wc -l etc... Please let me know how to change the line separator temporarily to run these unix commands.
Thanks. (1 Reply)
Hi... I can't find my little red AWK book and it's been a long while since I've awk'd. But I need to take a CSV file and convert the first word of the fifth field to its own field by replacing a space with a comma.
This is for importing a spreadsheet of issues into JIRA...
Example:
a line... (9 Replies)
I can obtain information from itdt inventory command however it display as below, I'd like to print each entity on one line but seperated by :
the file is something like and each section ends with Volume Tag
Drive Address 256
Drive State ................... Normal
ASC/ASCQ... (3 Replies)
Hi All,
I'm trying to view data using cut command for a fixed length file using the below command:
cut -c 1-3,4-5 FALCON_PIS_00000000.dat
I want to mention a separator say | (pipe) in between 1-3 and 4-5.
Please let me know how to achieve this.
Thanks in Advance, (3 Replies)
not sure how to do it. wan't to delete it using cut and grep ince i would use it in the shell.
but how must the command be?
grep "64.233.181.103 wwwGoogle.com" /etc/hosts | cut -d
the delimeter is just a space. can you help meplease. :D (1 Reply)
I have a file like name file.txt whose contents are 3 fields separated by colon':' . somewhat like
code/OR_R1400_RC4/BM_ATEMP_11.0.1.33:28/01/2010:N
code/OR_R1400_RC5/BM_ATEMP_11.0.1.35:28/01/2010:Y
code/OR_R1400_RC4/BM_ATEMP_11.0.1.33:29/01/2010:N... (8 Replies)
i need to cut the string in a textfile but each line has a specific way of cutting it (different lengths)
i have a for loop that gets the string line per line, then each line has to be compared:
for x in `cat tmp2.txt`; do
if; then
echo 'BAC'
elif
... (6 Replies)
Hi All,
I've got some strange behaviour going on when trying to manipulate a file that contains spaces.
My input file looks something like this:
xxxxxxxxx,yyyy,sss sss sss,bbbbbbb
If I use awk:
When running from the command line I get:
sss sss sss
But when running from a... (7 Replies)