First let us start with the standard questions that should be answered in your first post in any technical thread:
What operating system are you using?
What shell are you using?
What have you tried to solve this problem on your own?
Then we can move on to details specific to this thread:
Numbers do not contain underscore characters. Why do you call 001_1_174 a number?
What criteria are to be used to decide if the first column in an input line is numeric?
Is the criteria that the second field on a line is the string "j"?
Can your numbers have leading plus or minus signs?
Can your numbers have decimal points? If so, what is your decimal point character?
Can your numbers have thousands separators?
Can your numbers have a leading or trailing currency symbol?
Where is this table that you have?
What is the format of this table?
If you want us to do your work for you, you can at least give us the details needed to figure out what must be done. Note that we are here to help you learn how to write your own code. We are not here to act as your unpaid programming staff.
What have you tried to solve this problem on your own?
[/quote]
no i dont know awk well
sorry, they are not number but strings just contain numbers and underline_
[quote]
What criteria are to be used to decide if the first column in an input line is numeric?
[/quote]
not numeric,strings just contain numbers and underline_
[quote]
Is the criteria that the second field on a line is the string "j"?
[/quote]
no, second field contain [a-z] and ./`'`][
[quote]
Can your numbers have leading plus or minus signs?
[/quote]
no just digits
[quote]
Can your numbers have decimal points? If so, what is your decimal point character?
[/quote]
no, numbers just plus digits contain [0-9]
[quote]
Can your numbers have thousands separators?
[/quote]
no
[quote]
Can your numbers have a leading or trailing currency symbol?
[/quote]
just digits
[quote]
Where is this table that you have?
[/quote]
out of a code
[quote]
What is the format of this table?
[/quote]
text.
so glad to explain me. so thanks. this is not commercial code just my Thesis.
Thanks for being that open. Usually students' home- and coursework questions need to be posted in the in this forum under special homework rules. A thesis in a non-IT field I think is a border line case. Did you consider awk to check for NF (number of fields) equals 4 (save $1 then) or less than 4 (add saved $1 to begin-of-line then)?
There's text books on awk , and / or the man page. Look into these forums and try to understand the problems and track the solutions proposed. Start creating your own solutions to simple up to more complex problems.
If your thesis is in an IT related field, please post in the homework forum, filiing in the ENTIRE form. I presume you will correctly cite the source of any solutions you'll find in these forums.
Concering your answer to question VIII in post #3: If your table is in "out of a code", how is an awk script supposed to be able to read it? Are you saying that you have/will hard code the table into a BEGIN clause in your awk script?
Concerning your answer to question IX in post #3: If your table was in a file, the type "text" would say that there are no lines in the file containing more than LINE_MAX bytes (including the line-terminating <newline> characters, that the file contains no <NUL> bytes, and that if the file contains any characters at all the last character in the file is a <newline> character. That says nothing about how fields in your table are separated. It appears that you want the modified lines in your table to be written with the 1st field from the previous line whose first character is numeric followed by a single <space> character followed by the previous contents of that line of the table. Is that correct?
If you can't describe how this table exists, we have great difficulty in making any suggestions as to how to process the table. The art of programming is all about understanding the format and type of the input to be processed, the type and format of the output desired, and the rules that specify how the input needs to be transformed to produce the output.
One can learn a lot about awk (not AWK ; utility names on UNIX, Linux, and BSD systems are case sensitive), editors, and other utilities by reading their manual pages on your system. For example, you can see the manual page for awk by typing the command: man awk
into your shell at a command prompt.
You can also look at hundreds (if not thousands) of threads in this forum that contain awk scripts to solve lots of different kinds of problems. Many of those scripts have comments that document what every line in the script is doing. For those that don't, if the thread is still open you can always and a post to a thread asking for an explanation of how that script works (or how particular lines in that script work). Use the advanced search feature in this forum for threads with tag "solved" and keyword "awk" for a list of 500 threads with examples.
One classic book describing awk is The AWK Programming Language published Jan 11, 1988 and written by the three authors of the utility Alfred V. Aho, Peter J. Weinberger, and Brian W. Kernighan.
Are these question important to answer my question? you know speech recognition. label speech signal in phone and word by byte of input signal.
you assume that table save in a directory!
i think you say true.
i confuse. explain again.
i have a table that first line have four columns.
column one begin with digits and contain digits and underline. column two contain alphabet not digits and columns three and four contain only digits.
in following it has three columns similar before except first column.(color string)
i want copy color string in new lines until next new line begin by another (color) string
I don't ask questions for the fun of asking questions. I was trying to get you to directly answer the questions needed to determine whether or not you are seeking a degree in information technology. Since you are unwilling to answer the questions of what university you're attending and who your thesis advisor is, we have to assume that you are asking us to do your homework for you and it is important for you to hide this information from us.
Please review the rules, which you agreed to when you registered, if you have not already done so.
More-than-likely, posting homework in the main forums has resulted in a forum infraction.
For the record, the last thing I would assume is that you stored your table in a file of type directory. I assumed that you would have stored your table in:
a single shell variable,
a single shell array variable (with each element of the array being a line n your table),
in three or four shell array variables (with each array being a column in your table),
a regular file (which would be a preferred choice),
a shared memory segment,
in a pipe (or named FIFO) written to by a process that is creating the data in your table (which would also be a preferred choice),
hardcoded into an awk , bc , dc , ed , ex , or sed script, or
any of several less common ways of storing data.
Your refusal to tell us how your table is stored and in what form you want the output to be produced makes it impossible for us to even guess at what tool should be used to process your data.