Space Symbolism


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Space Symbolism
# 1  
Old 04-16-2008
Tools Space Symbolism

------------------------------------------------------------------------
Can please someone help me
First is this correct: while [ $string != "" ] how we symbolise space? I mean is "" correct?


and this var=`cut -f1 -d\"" $string` how we symbolise the space or blank character here? Is this -d\"" or -d " " correct. Because all them are wrong
# 2  
Old 04-16-2008
If there is no space between the quotation marks then it's the empty string, with no characters in it.

To symbolize a space, put a space between the quotation marks.

You can play with "echo" and "cat -A" to see what happens. (Your cat might use a slightly different option character.)

Code:
vnix$ echo "" | cat -A
$
vnix$ echo " " | cat -A
 $

The $ shows the end of line, so you can tell whether or not there was any whitespace. Or just put something around it:

Code:
vnix$ echo ."".
..
vnix$ echo ." ".
. .

\" means a literal double quote, so -d \"" is a syntax error (literal double quote followed by opening string quote, but no closing string quote). -d " " with a space between should work; doesn't it work for you? Backslash followed by space (-d \ )should also work, without any quote marks at all.
# 3  
Old 04-16-2008
Tools end of line

So how we symbolise the end of line in:
while [ $seira != "" ] . seira is a string that has blank spaces between the characters. I want to read it with while until end of line. how we symbolise it? Is the above correct
# 4  
Old 04-16-2008
What do you mean by "read it with while"? You need to show more of your code.

The above says "while $seira is not an empty string" so that seems vaguely like what you're after. (You should have double quotes around $seira though.)
# 5  
Old 04-16-2008
Tools Ok But

I have a file that has dates like this:
date FINAL_RESULT; 6
date FINAL_RESULT; 3
date FINAL_RESULT; 8

With this command: seira=`cut -f2 -d\; tes.txt` i take the date FINAL RESULTs and i store them on variable seira.then seira look like this: 6 3 8
I want to read seira and make a sum of all results 6+3+8 etc. i don't know how mane records there are in the file. So i want to read seira with the the next loop using while but it doesn 't work. i don't want to use grep or awk. I want to use while and cut but it is wrong. Can yoy help me please

while [ "$seira" != "" -a "$seira" != " " ]
do
sum=0
pros1=`cut -f1 -d \ $seira`
pros2=`cut -f2 -d \" " $seira`
sum=`expr $sum+$pros1`
seira=$pros2
done
# 6  
Old 04-16-2008
Tools hallo

I hope you haven't forgotten me, because i am in a big need right know
# 7  
Old 04-17-2008
Bug

Here is my liitle code. I hope this help. But i am also a beginner in shell scripting. I thought i will just give it a try!

I have the text in file bb

/home/gkalangi$ cat bb
date FINAL_RESULT; 6
date FINAL_RESULT; 3
date FINAL_RESULT; 8


the script to find the sum:

#!/bin/sh

seira=`cut -d\; -f2 bb`
echo $seira
sum=0

for num in `echo $seira`
do
sum=`expr $sum + $num`
done

echo $sum


Please let me know if it helped you!
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Gawk --- produce the output in pattern space instead of END space

hi, I'm trying to calculate IP addresses and their respective calls to our apache Server. The standard format of the input is HOST IP DATE/TIME - - "GET/POST reuest" "User Agent" HOST IP DATE/TIME - - "GET/POST reuest" "User Agent" HOST IP DATE/TIME - - "GET/POST reuest" "User Agent" HOST... (2 Replies)
Discussion started by: busyboy
2 Replies

2. Linux

No space left on device while there is plenty of space available

Hello all posting here after scanning the net and tried most of the things offered still no solution that worked when I do : $ df -h Filesystem Size Used Avail Use% Mounted on footmpfs 7.9G 60K 7.9G 1% /dev tmpfs 7.9G 0 7.9G 0% /dev/shm /dev/da1 ... (3 Replies)
Discussion started by: umen
3 Replies

3. UNIX for Advanced & Expert Users

Need to remove leading space from awk statement space from calculation

I created a awk state to calculate the number of success however when the query runs it has a leading zero. Any ideas on how to remove the leading zero from the calculation? Here is my query: cat myfile.log | grep | awk '{print $2,$3,$7,$11,$15,$19,$23,$27,$31,$35($19/$15*100)}' 02:00:00... (1 Reply)
Discussion started by: bizomb
1 Replies

4. UNIX for Dummies Questions & Answers

Difference between space and [[:space:]] in regular expression

May I know the difference between space in keyboard and ] in regular expression I entered the following find . -type f -print | xargs grep -n 'dt=' | cut -d":" -f3 | sed 's/^ *dt=/dt=/g' After "^" there is a space. and the result is... dt=`date +%Y%m%d%H%M%S` dt=`date +%Y%m%d`... (6 Replies)
Discussion started by: bobbygsk
6 Replies

5. UNIX for Dummies Questions & Answers

Changing only the first space to a tab in a space delimited text file

Hi, I have a space delimited text file but I only want to change the first space to a tab and keep the rest of the spaces intact. How do I go about doing that? Thanks! (3 Replies)
Discussion started by: evelibertine
3 Replies

6. Fedora

Need to incrwase PHYSICAL VOLUME space on hard drive with free space on it

Hi, I run Fedora 17. I created a physical volume of 30GB on a disk with 60GB of space so there is 30GB of free space. On the physical volume, I created my volume group and logical volumes. I assigned all the space in the physical volume to my volume group. I need to add the 30GB of free space... (1 Reply)
Discussion started by: mojoman
1 Replies

7. Solaris

No space left on device but free space and inodes are available...

hi guys, me again ;) i recently opened a thread about physical to zone migration. My zone is mounted over a "bigger" LUN (500GB) and step is now to move the old files, from the physical server, to my zone. We are talking about 22mio of files. i used rsync to do that and every time at... (8 Replies)
Discussion started by: beta17
8 Replies

8. Linux

How to reclaim the space which i used to increse the swap space on Xen,

Hi, i have done a blunder here, i increased the swap space on Xen5.6 server machine using below steps :- 1056 dd if=/dev/zero of=/root/myswapfile bs=1M count=1024 1057 ls -l /root/myswapfile 1058 chmod 600 /root/myswapfile 1059 mkswap /root/myswapfile 1060 swapon /root/myswapfile ... (1 Reply)
Discussion started by: apm
1 Replies

9. Shell Programming and Scripting

Calculate total space, total used space and total free space in filesystem names matching keyword

Good afternoon! Im new at scripting and Im trying to write a script to calculate total space, total used space and total free space in filesystem names matching a keyword (in this one we will use keyword virginia). Please dont be mean or harsh, like I said Im new and trying my best. Scripting... (4 Replies)
Discussion started by: bigben1220
4 Replies

10. UNIX for Advanced & Expert Users

wake up user space thread from kernel space ISR

Hello, I'm searching for a proper way to let the kernel space ISR(implemented in a kernel module) wake up a user space thread on a hardware interrupt. Except for sending a real-time signal, is it possible to use a semaphore? I've searched it on google, but it seems impossible to share a... (0 Replies)
Discussion started by: aaronwong
0 Replies
Login or Register to Ask a Question