how to use cut function to obtain this data out in script?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting how to use cut function to obtain this data out in script?
# 1  
Old 12-12-2005
how to use cut function to obtain this data out in script?

Hi....can you guys help me out in this script??

Below is a text file script....called Bukom.txt and it contains these:

BUKOM 20060101 2.5 2.6 2.7 2.8 2.9 2.3 2.1
BUKOM 20060102 2.4 2.5 2.6 2.7 2.7 2.6 2.4
BUKOM 20060103 2.1 2.3 2.5 2.6 2.7 2.7 2.6

Can you guys help me on coding using cut function?
i need the word"BUKOM " to be echo out and with the trailing spaces removed...and i need to use cut fucntion to cut out the date "20060101" and also to cut out "2.5", "2.6" etc...and store each with different variables...can anyone help? im quite lost here.. Smilie maybe i can use sed too?
# 2  
Old 12-12-2005
Code:
cut -f1 -d" " Bukom.txt #Give the first column
cut -f2 -d" " Bukom.txt #Give the second column

The first command will display
Code:
BUKOM
BUKOM
BUKOM

The second command will display
Code:
20060101
20060102
20060103

Use head or tail command if you want to return only one row
The below statement will store the result in a variable
Code:
first=`cut -f2 -d" " Bukom.txt | head -1`

# 3  
Old 12-12-2005
thanks mona!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Using :<<cut / cut to comment out block of bash script

I am using : << cut / cut to comment out block of code. Works fine on few lines of script, then it gives me this cryptic error when I try to comment out about 80 lines. The "warning " is at last line of script. done < results 169 echo "END read all positioning parameters" 170... (8 Replies)
Discussion started by: annacreek
8 Replies

2. Shell Programming and Scripting

Cut the data with a string that has \ in it

Hi Team, Here's the record in a file. abc\USER DEFINED\123\345\adf\aq1 Delimiter here is "\USER DEFINED\" Expected output: abc|123\345\adf\aq1 Find "\USER DEFINED\" and replace it with "|". Can anyone please help us to fix this issue? Please use CODE tags as required by... (5 Replies)
Discussion started by: kmanivan82
5 Replies

3. Programming

Writing a UNIX shell script to call a C function and redirecting data to a .txt file

Hi, I am complete new to C programming and shell scripting. I just wrote a simple C code to calculate integral using trapezoid rule. I am prompting user to pass me No. of equally spaced points , N , upper and lower limit. My code looks as follows so far: #include<stdio.h> #include<string.h>... (2 Replies)
Discussion started by: bjhjh
2 Replies

4. Shell Programming and Scripting

Need to cut a some required data from file

Data_Consolidation_Engine_Part_2_Job2..TgtArBkt: ORA-00942: table or view does not exist I have some thing like above in the file.. Upto this portion Data_Consolidation_Engine_Part_2_Job2..TgtArBkt: the length can be vary .. Can some one help me in taking this portion alone ORA-00942:... (7 Replies)
Discussion started by: saj
7 Replies

5. Shell Programming and Scripting

How i can obtain differents data on a single pass?

#!/bin/bash for i in `ls -c1 /usr/share/applications` do #name=`cat /usr/share/applications/$i | grep ^Name= | cut -d = -f2` #categories=`cat /usr/share/applications/$i | grep ^Categories= | sed 's/;/=/g' | cut -d = -f2` name=$(grep ^Name= /usr/share/applications/$i | cut -d = -f2)... (12 Replies)
Discussion started by: alexscript
12 Replies

6. UNIX for Dummies Questions & Answers

cut function in linux

hi; i have file with a lote of data i would like to cut only numbers that start with prefix 20408 my file contain thousands of rows like this ,204080700152648,20111215,,,20 31630536259,204080662332510,20 31622520779,204080660098298,20 31651343790,204080130071280,20... (2 Replies)
Discussion started by: kpinto
2 Replies

7. Homework & Coursework Questions

Shell script calling Perl function, sort and find data, write to new files

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: I must write a shell script that calls two external Perl functions--one of which sorts the data in a file, and... (6 Replies)
Discussion started by: kowit010
6 Replies

8. Shell Programming and Scripting

Expect script: obtain the exit code of remote command

Hi all, I'm trying to run the sipp simulator in crontab but after some attempt I came to the conclusion that for some reason this isn't possible (maybe due to sipp interactive nature). This is confirmed by these posts. Now I'm trying to launch sipp from an expect script that runs in crontab. ... (0 Replies)
Discussion started by: Evan
0 Replies

9. Shell Programming and Scripting

Cut Data In Bigfile

I want to create new file for 'NO 0004/01' and 'NO 0005/01' only How can i do It for shot time Data FILE Data.txt (Data ~1,000,000 Line) START NO 0001/01 HEAD AAAA BODY1 AAA BODY2 AAA TAIL AAA END START B1 NO 0001/02 HEAD AAAA BODY1 AAA BODY2 AAA BODY3 AAA TAIL AAA (2 Replies)
Discussion started by: kittiwas
2 Replies

10. Shell Programming and Scripting

How to cut, concatenate data in Shell Script

Hello All,, I'm very new to Unix and I'm more in SAP ABAP. I have a requirement for a shell script which will accept one parameter as Input file name(with directory) e.g : /sapdata/deubank/dbdirect/out/deu01deupe/in/deu01deupe20051207111320.pmt In the shell script I have to make two more... (2 Replies)
Discussion started by: vasan_srini
2 Replies
Login or Register to Ask a Question