ksh questions - Reading columns and lines on unix


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting ksh questions - Reading columns and lines on unix
# 1  
Old 12-20-2008
ksh questions - Reading columns and lines on unix

1-) For the command below, I want to read second column: 32751. How will I get it ?
$ ps -ef|grep deneme
U00 32751 22745 0 16:30 pts/1 00:00:00 ksh deneme
U00 32762 32132 0 16:30 pts/2 00:00:00 grep deneme

2-) For the command below, how will I read all lines line by line? For example with a while statement, I should read them line by line :deneme, HelloWorld.class,etc.
$ ls -l
total 20
-rwxrwxrwx 1 U00 U00 147 Dec 19 16:29 deneme
-rwxrwxrwx 1 U00 U00 431 Dec 19 14:47 HelloWorld.class
drwxrwxr-x 6 U00 U00 4096 Dec 19 14:30 jdk1.5.0_16
drwxrwxr-x 4 U00 U00 4096 Dec 19 14:08 jre1.6.0_07
drwxrwxr-x 4 U00 U00 4096 Dec 19 12:46 jre6
# 2  
Old 12-20-2008
Search for "while read loop" with the Google custom search right above the page.
It should give you a bunch of threads regarding this topic.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Reading columns using arrays

Hello, Please help in how to read rows and columns using array and print them. I have below output and i want to store this in array and print the required rows or columns. aaaaaaa 123 bbbbbb 456 ccccccc 888 Use code tags, thanks. (1 Reply)
Discussion started by: Cva2568
1 Replies

2. Shell Programming and Scripting

Merging multiple lines to columns with awk, while inserting commas for missing lines

Hello all, I have a large csv file where there are four types of rows I need to merge into one row per person, where there is a column for each possible code / type of row, even if that code/row isn't there for that person. In the csv, a person may be listed from one to four times... (9 Replies)
Discussion started by: RalphNY
9 Replies

3. Shell Programming and Scripting

Reading multiple values from multiple lines and columns and setting them to unique variables.

Hello, I would like to ask for help with csh script. An example of an input in .txt file is below, the number of lines varies from file to file and I have 2 or 3 columns with values. I would like to read all the values (probably one by one) and set them to independent unique variables that... (7 Replies)
Discussion started by: FMMOLA
7 Replies

4. Shell Programming and Scripting

ksh sed - Extract specific lines with mulitple occurance of interesting lines

Data file example I look for primary and * to isolate the interesting slot number. slot=`sed '/^primary$/,/\*/!d' filename | tail -1 | sed s'/*//' | awk '{print $1" "$2}'` Now I want to get the Touch line for only the associate slot number, in this case, because the asterisk... (2 Replies)
Discussion started by: popeye
2 Replies

5. Programming

Reading multiple columns in C++

Dear all, I am novice in C+= programing. I would like to seek help in one of the progra. Here it is, I have txt file which has the data as following order varA varB -21 0 -21.2 3, 4, 5, 6 -21.4 45, 65, 87, 98, 98 -22.0 345677, 349887, 98766, 877654, 987543 -23.0 76549,... (17 Replies)
Discussion started by: emily
17 Replies

6. Shell Programming and Scripting

How to ignore single or multiple lines between /* and */ while reading from a file in unix?

I have a file proc.txt: if @debug = 1 then message 'Start Processing ', @procname, dateformat(now(*), 'hh:mm:ss'), @julian type info to client; end if; /* execute immediate with quotes 'insert into sys_suppdata (property, value, key_name) location ''' || @supp_server || '.' ||... (5 Replies)
Discussion started by: kidncute
5 Replies

7. Shell Programming and Scripting

Reading two lines in a while loop and combining the lines

Dear all, I have a file like this: imput scaffold_0 1 scaffold_0 10000 scaffold_0 20000 scaffold_0 25000 scaffold_1 1 scaffold_1 10000 scaffold_1 20000 scaffold_1 23283 and I want the output like this: scaffold_0 1 scaffold_0 10000 scaffold_0 10000 scaffold_0 20000... (6 Replies)
Discussion started by: valente
6 Replies

8. Shell Programming and Scripting

reading from file in ksh

hi, it seems i can read using cat file | while read line but when i tried reading using while read line < myfile then the last line kept on being returned why? thanks (2 Replies)
Discussion started by: JamesByars
2 Replies

9. Shell Programming and Scripting

reading lines in pairs from file in ksh

I need to read pairs of lines from a file and compare them. We can assume that the number of lines in the file is even. Can i do it in korn shell? (4 Replies)
Discussion started by: ytokar
4 Replies

10. UNIX for Advanced & Expert Users

Reading lines within a Unix file.

I have a file that has a list of numbers in it. Each line has a different number. I am trying to create some sort of loop within a script that will pick the numbers up on lines 1 and 2 and then put those figures into the script. It then goes through the process then loops back and reads lines 2 and... (5 Replies)
Discussion started by: mariner
5 Replies
Login or Register to Ask a Question