awk copy first column in new lines


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting awk copy first column in new lines
# 8  
Old 02-05-2018
IF your thesis is in an IT- related field, and IF the hint given in post#4 does not suffice, please repost in the homework forum.
# 9  
Old 02-05-2018
Quote:
Originally Posted by alii
Smilie
can't thesis about IT-field?Smilie
Please write your answers as complete sentences.
Quote:
Originally Posted by alii
may help me or NOT?
In what field of study is your research?

What is the title of your thesis?

What degree are you seeking?

Who is your thesis advisor?

At what university are you studying?

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.

Last edited by vbe; 02-05-2018 at 01:16 PM.. Reason: typo: missing i...
# 10  
Old 02-05-2018
Thank you for giving me your time.Smilie
Quote:
Originally Posted by Don Cragun
Please write your answers as complete sentences.

In what field of study is your research?

What is the title of your thesis?

What degree are you seeking?

Who is your thesis advisor?

At what university are you studying?
Are these question important to answer my question? you know speech recognition. label speech signal in phone and word by byte of input signal.

Quote:
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?
you assume that table save in a directory!
Quote:
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?
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
Code:
input
001_1_174    [g/n                         474536         482492          
mo[g/n                    482492         504062          
'er/                      504062         517352          
ruze                      517352         529562                  
001_1_175    uz[`f                         960192         966656           
.ire                      966656         984416           
tuf/[                     984416         1006166

Code:
001_1_174    [g/n                         474536         482492           
001_1_174  mo[g/n                    482492         504062           
001_1_174  'er/                      504062         517352           
001_1_174  ruze                      517352         529562                  
001_1_175    uz[`f                         960192         966656           
001_1_175   .ire                      966656         984416           
001_1_175   tuf/[                     984416         1006166

Quote:
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.
Quote:
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:
[CODE]man awk[ICODE]
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.
thanksSmilie
# 11  
Old 02-05-2018
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.

Homework and coursework questions can only be posted in the Homework & Coursework Questions forum under special homework rules.

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.

This thread is closed.
This User Gave Thanks to Don Cragun For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Awk,sed,shell copy ID in new lines

Hi all i want table file in pattern like under ID(digits and underline) phonetic begin_byte(only plus number) end_byte(only plus number) but ID loose in next lines of my file my input file like this: input 001_1_174 474536 482492 mo 482492 504062 'er/ 504062 517352 ruze 517352... (1 Reply)
Discussion started by: alii
1 Replies

2. Shell Programming and Scripting

Read first column and count lines in second column using awk

Hello all, I would like to ask your help here: I've a huge file that has 2 columns. A part of it is: sorted.txt: kss23 rml.67lkj kss23 zhh.6gf kss23 nhd.09.fdd kss23 hp.767.88.89 fl67 nmdsfs.56.df.67 fl67 kk.fgf.98.56.n fl67 bgdgdfg.hjj.879.d fl66 kl..hfh.76.ghg fl66... (5 Replies)
Discussion started by: Padavan
5 Replies

3. Shell Programming and Scripting

awk to filter out lines containing unique values in a specified column

Hi, I have multiple files that each contain four columns of strings: File1: Code: 123 abc gfh 273 456 ddff jfh 837 789 ghi u4u 395 File2: Code: 123 abc dd fu 456 def 457 nd 891 384 djh 783 I want to compare the strings in Column 1 of File 1 with each other file and Print in... (3 Replies)
Discussion started by: owwow14
3 Replies

4. Shell Programming and Scripting

awk Print New Column For Every Two Lines and Match On Multiple Column Values to print another column

Hi, My input files is like this axis1 0 1 10 axis2 0 1 5 axis1 1 2 -4 axis2 2 3 -3 axis1 3 4 5 axis2 3 4 -1 axis1 4 5 -6 axis2 4 5 1 Now, these are my following tasks 1. Print a first column for every two rows that has the same value followed by a string. 2. Match on the... (3 Replies)
Discussion started by: jacobs.smith
3 Replies

5. UNIX for Dummies Questions & Answers

awk solution to duplicate lines based on column

Hi experts, I have a tab-delimited file with one column containing values separated by a comma. I wish to duplicate the entire line for every value in that comma-delimited field. For example: $cat file 4444 4444 4444 4444 9990 2222,7777 6666 2222 ... (3 Replies)
Discussion started by: torchij
3 Replies

6. Shell Programming and Scripting

Find duplicates in column 1 and merge their lines (awk?)

Hi, I have a file (sorted by sort) with 8 tab delimited columns. The first column contains duplicated fields and I need to merge all these identical lines. My input file: comp100002 aaa bbb ccc ddd eee fff ggg comp100003 aba aba aba aba aba aba aba comp100003 fff fff fff fff fff fff fff... (5 Replies)
Discussion started by: falcox
5 Replies

7. Shell Programming and Scripting

Awk to display lines that contain a period only in the first column

I've been trying to figure this out for quite a bit... I'm trying to check the first column for a period and only display the line if it contains a period. Below is a sample of the data i'm working with. www.homestorest 7200 IN CNAME www.homestorest.fishing.net.shopit.net.... (6 Replies)
Discussion started by: spartan22
6 Replies

8. Shell Programming and Scripting

Copy respective path next to last column with awk

Hi to all, I have the short print out sample of the DOS command "dir S/" as showed below. Directory of C:\Program Files\Winamp\Skins\Bento\window 02/12/2010 11:35 p.m. <DIR> . 02/12/2010 11:35 p.m. <DIR> .. 11/12/2009 10:31 a.m. 13,556... (3 Replies)
Discussion started by: cgkmal
3 Replies

9. Shell Programming and Scripting

awk/grep copy and paste and insert in between lines.

Hi all, I'm a unix newb andI'm trying to write a script that can copy some text paste it in a certian place and then add a number. It's not really clear but I'll show an example. what the file looks like right now: Linux 2.6.24-24-generic (abc) 07/15/09 23:25:01 CPU ... (6 Replies)
Discussion started by: the1hand3r
6 Replies

10. Shell Programming and Scripting

How to copy multiple lines from a file to another using AWK?

Hi, I have a abc.txt file. In this file there is a SQL query which Iwant to copy and print it on another file.The query (for eg) is written like this: SELECT field1, field2, field3 from table1,table2 where <conditions> END I want to copy this query to another... (3 Replies)
Discussion started by: jisha
3 Replies
Login or Register to Ask a Question