Convert fixed value fields to comma separated values
Hi All,
Hope you are doing Great!!!.
Today i have came up with a problem to say exactly it was for performance improvement.
I have written code in perl as a solution for this to cut in specific range, but it is taking time to run for files thousands of lines so i am expecting
a sed command kind of thing to make it run quickly.
input format:
output format required:
I have a file with input format given as example in above.
Rules for input format:
The "--> TP ID:" will repeat for every three lines.
All the values after ":" were variable in length with in length given to it but all the values before ":" was fixed in length.
So our motivation was to make the values after ":" to be like in output format with comma separated value.
I am using AIX V6.0 OS. SED command as solution will be a preferable .
Thanks.
---------- Post updated at 11:03 PM ---------- Previous update was at 11:01 PM ----------
I have pasted actual data but i could see a empty line in between every 3 lines but in actual data there will not be any empty lines in input file.
Hello all,
I am a unix dummy. I am trying to remove spaces between fields. I have the file in the following format
12332432, 2345 , asdfsdf ,100216 , 9999999
12332431, 2341 , asdfsd2 ,100213 , 9999999
&... (2 Replies)
I have a situation where I am reading a text file line-by-line. Those lines of data contain comma separated fields of data. However, each line can vary in the number of fields it can contain. What I need to do is parse apart each line and write each field of data found (left to right) into a file.... (7 Replies)
Hi,
I have a variable which has a list of string separated by comma.
for ex ,
Variable=/usr/bin,/usr/smrshbin,/tmp
How can i get the values between the commas separately using shell scripts.Please help me.
Thanks,
Padmini. (6 Replies)
Hi
pls help me to get the code:
i have a file in which content is :
2.01304E+11 2.01304E+11 ori 2 01:00
2.01304E+11 2.01304E+11 ori 2 01:02
2.01304E+11 2.01304E+11 ori 3 01:02
2.01304E+11 2.01304E+11 ori 3 ... (7 Replies)
Hi,
I have a large number of files which are written as csv (comma-separated values).
Does anyone know of simple sed/awk command do achieve this?
Thanks!
---------- Post updated at 10:59 AM ---------- Previous update was at 10:54 AM ----------
Guess I asked this too soon. Found the... (0 Replies)
hello experts,
i am retrieving values in variables jobKey and jobName within my shell script. these values are returned to me within braces and i am using following command to remove those braces:
jobKeys=`echo $jobKeys | sed 's:^.\(.*\).$:\1:'`
jobNames=`echo $jobNames | sed... (1 Reply)
Hi,
I have a list of tables in a file.txt
C_CLAIM
C_HLD
C_PROVIDER
I want the output to be
'C_CLAIM','C_HLD','C_PROVIDER'
Currently I'm usin awk and getting output which is almost correct but still has minor defects
awk -vORS="','" '{ print $1 }' file.txt
The output of... (4 Replies)
My OS : RHEL 6.7
I have a text file with comma separated values like below
$ cat testString.txt
'JOHN' , 'KEITH' , 'NEWMAN' , 'URSULA' , 'ARIANNA' , 'CHENG', . . . .
I want these values to appear like below
'JOHN' ,
'KEITH' ,
'NEWMAN' ,
'URSULA' ,
'ARIANNA' ,
'CHENG',
.... (4 Replies)
can anyone help me!!!! How to I parse the CSV file
file name : abc.csv (csv file) The above file containing data like
abv,sfs,,hju,',',jkk wff,fst,,rgr,',',rgr ere,edf,erg,',',rgr,rgr I have a requirement like i have to extract different field and assign them into different... (4 Replies)
Discussion started by: J.Jena
4 Replies
LEARN ABOUT HPUX
cut
cut(1) General Commands Manual cut(1)NAME
cut - cut out (extract) selected fields of each line of a file
SYNOPSIS
list [file]...
list [file]...
list char] [file]...
DESCRIPTION
cuts out (extracts) columns from a table or fields from each line in a file; in data base parlance, it implements the projection of a rela-
tion. Fields as specified by list can be fixed length (defined in terms of character or byte position in a line when using the or option),
or the length can vary from line to line and be marked with a field delimiter character such as the tab character (when using the option).
can be used as a filter; if no files are given, the standard input is used.
When processing single-byte character sets, the and options are equivalent and produce identical results. When processing multi-byte char-
acter sets, when the and options are used together, their combined behavior is very similar, but not identical to the option.
Options
Options are interpreted as follows:
list A comma-separated list of integer byte option), character option), or field option) numbers, in increasing order,
with optional to indicate ranges. For example:
Positions 1, 4, and 7.
Positions 1 through 3 and 8.
Positions 1 through 5 and 10.
Position 3 through last position.
Cut based on a list of bytes.
Each selected byte is output unless the option is also specified.
Cut based on character positions specified by
list extracts the first 72 characters of each line).
Where list is a list of fields assumed to be separated in the file by a delimiter character (see for example, copies the
first and seventh field only. Lines with no field delimiters will be passed through intact (useful for table sub-
headings), unless is specified.
The character following
is the field delimiter option only). Default is tab. Space or other characters with special meaning to the shell
must be quoted. Adjacent field delimiters delimit null fields. char may be an international code set character.
Do not split characters.
If the high end of a range within a list is not the last byte of a character, that character is not included in the
output. However, if the low end of a range within a list is not the first byte of a character, the entire character
is included in the output."
Suppresses lines with no delimiter characters when using
option. Unless is specified, lines with no delimiters appear in the output without alteration.
Hints
Use to extract text from a file based on text pattern recognition (using regular expressions). Use to merge files line-by-line in columnar
format. To rearrange columns in a table in a different sequence, use and See grep(1) and paste(1) for more information.
EXTERNAL INFLUENCES
Environment Variables
determines the interpretation of text as single and/or multi-byte characters.
If is not specified in the environment or is set to the empty string, the value of is used as a default for each unspecified or empty vari-
able. If is not specified or is set to the empty string, a default of "C" (see lang(5)) is used instead of If any internationalization
variable contains an invalid setting, behaves as if all internationalization variables are set to "C". See environ(5).
International Code Set Support
supports both single- and multi-byte character code sets. International code set characters may be specified in the char given to the
option. recognizes the international code set characters according to the locale specified in the environment variable.
EXAMPLES
Password file mapping of user ID to user names:
Set environment variable to current login name:
Convert file containing lines of arbitrary length into two files where contains the first 500 bytes (unless the 500th byte is within a
multi-byte character), and contains the remainder of each line:
DIAGNOSTICS
Line length must not exceed
characters or fields, including the new-line character (see limits(5).
Missing or option or incorrectly specified list. No error occurs if a line has fewer fields than the list calls for.
list is empty.
WARNINGS
does not expand tabs. Pipe text through expand(1) if tab expansion is required.
Backspace characters are treated the same as any other character. To eliminate backspace characters before processing by use the or com-
mand (see fold(1) and col(1)).
AUTHOR
was developed by OSF and HP.
SEE ALSO grep(1), paste(1).
STANDARDS CONFORMANCE cut(1)