Shell help needed


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Shell help needed
# 8  
Old 11-17-2005
For supressing the spaces u can use

tr -s ' '


And if u have both tabs and spaces in ur file u can use awk instead of cut.

for ex:

instead of
cut -f3 -d" "

U can use
awk '{print $3}'
# 9  
Old 11-17-2005
I have a file like this....

BSC5-64-1 BSC7-1-1 99.00 99.00
BSC5-64-2 BSC7-1-1 98.00 98.00
BSC7-1-1 BSC7-1-2 -1.00 -1.00
BSC7-1-1 BSC7-1-3 -1.00 -1.00
BSC5-70-1 BSC7-1-1 99.00 99.00
BSC5-70-2 BSC7-1-1 99.00 99.00
BSC7-1-1 BSC7-2-1 -1.00 0.00
BSC7-1-1 BSC7-2-2 17.00 17.00
BSC7-1-1 BSC7-2-3 0.00 4.00
BSC7-1-1 BSC7-3-1 9.00 10.00
BSC7-1-1 BSC7-3-2 34.00 27.00
BSC7-1-1 BSC7-3-3 21.00 26.00
..........................................................
..........................................................
BSC7-1-1 BSC7-4-1 19.00 13.00
BSC7-1-1 BSC7-4-2 35.00 6.00
BSC7-1-1 BSC7-4-3 14.00 23.00
BSC7-1-1 BSC7-5-1 36.00 44.00
BSC7-1-1 BSC7-5-2 44.00 23.00
BSC5-64-1 BSC7-1-1 99.00 99.00
BSC5-64-2 BSC7-1-1 98.00 98.00
i need format this file so...
if first column is BSC7-1-1, then its ok..
else move second column to first and 4-th to 3-d..
....
can anyone help me????/
# 10  
Old 11-18-2005
This is a different question so you should really start a new thread, but anyway try this...
Code:
awk '$1!="BSC7-1-1"{$0=$2 FS $1 FS $4 FS $3}1' file1

# 11  
Old 11-21-2005
Question

Regarding my first question I'm using Mona's code but when I try to calculate a number bigger than 2500000000 it give the wrong answer. I guess some where around 2500000000 is the max number but is there a way to do calculations using numbers bigger than 2500000000?

e.g. Input file with below:

AAA Unit1 2500000000 500000000

using Mona's code it should output "AAA 0.2" but it outputs "AAA -0.27"
# 12  
Old 11-28-2005
Quote:
Originally Posted by stevefox
Regarding my first question I'm using Mona's code but when I try to calculate a number bigger than 2500000000 it give the wrong answer. I guess some where around 2500000000 is the max number but is there a way to do calculations using numbers bigger than 2500000000?

e.g. Input file with below:

AAA Unit1 2500000000 500000000

using Mona's code it should output "AAA 0.2" but it outputs "AAA -0.27"
Did you find any solution for this? It works fine for me. I am getting the below output,

AAA .20
BBB .75
CCC .50

provided the input is,

AAA Unit1 60 39
AAA Unit7 30 15
AAA Unit1 2500000000 500000000
BBB Unit3 80 60
CCC Unit4 50 25
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script - help needed

I want to take out the Z1 value from the lscfg outpu and use the below command to get it lscfg -vl hdisk0 | grep "Device Specific.(Z1)" | awk -F. '{print $NF}' # lscfg -vpl hdisk0 . . Device Specific.(Z0)........0000063268181002 Device Specific.(Z1)........020064a . And it works,... (2 Replies)
Discussion started by: moorthikv
2 Replies

2. Shell Programming and Scripting

Help needed with shell script

Hi, I have trouble building the logic for the following, could anyone please help me out with this: Im working on a wrapper script to check for input files (in a specific directory) and pass the input files along with the options as parameters to the main script.The options vary depending ... (2 Replies)
Discussion started by: stunnerz_84
2 Replies

3. Shell Programming and Scripting

Help needed with Shell scripting

Hi All, I need to split a flatfile based on it's first character, I am using the following script awk '{print > "TEST_substr($0,1,1).txt"}' PROVIDER.txt It is returning files TEST_1 and TEST_2 But I am not getting the .txt file extension. I need the files like TEST_1.txt and ... (1 Reply)
Discussion started by: sam35
1 Replies

4. UNIX for Dummies Questions & Answers

Help needed with Shell script

Hi I want a script which should basically do 1. If the size of the file is 0kb, send email to some list od ppl 2. if the size of the file is other than 0kb send email to someother list... Pls help (2 Replies)
Discussion started by: win4luv
2 Replies

5. Shell Programming and Scripting

Shell script help is needed

I have a file test.txt and i need to grep pattern "A.17" from that file. I know cat test.txt | grep A.17 will return the pattern, but it is returing like # VERSION=A.17 How can i take only A.17 from this if A.17 is found, ... do something if not found ... do something Please... (11 Replies)
Discussion started by: Renjesh
11 Replies

6. Shell Programming and Scripting

help needed for a shell script

i need to search the starting line example we have -sh shl-js-gd i need to search only starting -sh not the other i have used cmd cat filename | grep '-' but it will check for complete - in the file please help me to search only starting - thank u revenna (0 Replies)
Discussion started by: revenna
0 Replies

7. Shell Programming and Scripting

shell script help needed

I am trying to query a table having 3 columns, the third column is a field of varchar(1024) with a SQL string in it. I am using cut command to split out the three fields into three variables. I do a db2 command to extract the data into a file. My problem is with the third field having the SQL... (3 Replies)
Discussion started by: fastgoon
3 Replies

8. Shell Programming and Scripting

SHell Scripting Help Needed

Dear All, I have an input file like this interface Serial10/0/7:11.1 point-to-point description CLIENT:SA_INSTITUTO ANGLO MEXICANO Sitio Metepec 104452:0,165 bandwidth 64 ip vrf forwarding INSTITUTO-ANGLO ip address 192.168.148.217 255.255.255.252 no ip directed-broadcast frame-relay... (2 Replies)
Discussion started by: cskumar
2 Replies

9. Shell Programming and Scripting

K Shell Help needed

Could someone tell me the code for doing the below inside a k shell? I have a file file below: $ more file1 >>>>> AAA BBB CCC <<<<< >>>>> DDD EEE FFF <<<<< I want the lines between ">>>>>" and "<<<<<" to be one line like below: AAA BBB CCC (2 Replies)
Discussion started by: stevefox
2 Replies

10. Shell Programming and Scripting

Korn Shell Help Needed

How do I change directories to a path given by input variable in Korn Shell? e.g. I tired with the Korn Shell below but it doesn't work. ---------------------------------- #!/bin/ksh echo "Enter folder name: \c" read folder cd $folder ---------------------------------- Any help will... (5 Replies)
Discussion started by: stevefox
5 Replies
Login or Register to Ask a Question