Sponsored Content
Top Forums Shell Programming and Scripting bash shell script string comparison Post 302311657 by bonosungho on Wednesday 29th of April 2009 09:09:47 AM
Old 04-29-2009
bash shell script string comparison

I want to remove a line that has empty string at second field when I use cut with delimeter , like below
Code:
$cat demo
hello, mum
hello,
 
#!/bin/sh
 
while read line
do
if [ `cut -f 2 -d "," "$line" = "" ]
then
    # remove the current line command goes here
fi
done < "demo"

i got an error message for above command and I have no idea how to remove current line

can I use
Code:
sed 's/$0//'

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Problem in ksh script ( String comparison )

hi , i am trying to compre two strings if ] or if ] when the length of var1 is small (around 300-400 char ) it works fine but when it is large (around 900-1000 chars) it fails is there any limitations for this type of comparison ??? (3 Replies)
Discussion started by: amarnath
3 Replies

2. AIX

Problem in ksh script ( String comparison )

hi , i am trying to compre two strings if ] or if ] when the length of var1 is small (around 300-400 char ) it works fine but when it is large (around 900-1000 chars) it fails is there any limitations for this type of comparison ??? (1 Reply)
Discussion started by: amarnath
1 Replies

3. Shell Programming and Scripting

problem in string comparison in shell programming

Hello, was just wondering how to compare strings in unix? I mean as in C there is a function strcmp() in string.h, is there any function in unix for that? I tried using if and all such variations but didn't succeed. Any help would be appreciated. Thanks in advance :) (9 Replies)
Discussion started by: salman4u
9 Replies

4. Shell Programming and Scripting

need help in writing a comparison shell script

I have a folder a1 with the following files sample_1.log sample_2.log sample_3.log sample_4.log sample_5.log sample_6.log In another folder there is a file b with the value 5 My script should take the value 5 ( file b), compare it with the files in folder a1, if file name contains... (1 Reply)
Discussion started by: Nagesh1
1 Replies

5. Homework & Coursework Questions

Date comparison with 'string date having slashes and time zone' in Bash only

1. The problem statement, all variables and given/known data: I have standard web server log file. It contains different columns (like IP address, request result code, request type etc) including a date column with the format . I have developed a log analysis command line utility that displays... (1 Reply)
Discussion started by: TariqYousaf
1 Replies

6. Solaris

String Comparison in Shell script

I Have a script which gets the status of oracle database and if the status is READ WRITE ..it should echo "db is up " else "db is down" Here is the code if then echo "db up" else echo "db down" fi done; The script is giving me out put "db down" even thoug the value of... (6 Replies)
Discussion started by: njafri
6 Replies

7. Shell Programming and Scripting

SPLIT STRING in bash shell script

i need one help.... if i have a string like aaaaa,bbbbb,ccccc,aaaaa How to to split the string and check howmany times aaaaa will be in that string? Thanks (7 Replies)
Discussion started by: karthinvk
7 Replies

8. Shell Programming and Scripting

String comparison using bash

I have a program to create a directory if not present. Here is the program. FYI: Directory name format: YYYY_MM_DD #!/bin/bash date=`date +%Y_%m_%d` presence=$(ls -lrt /TS_File/ | grep "$date" | awk '{print $9}') if then mkdir /TS_File/$date else echo "Unable to Create... (5 Replies)
Discussion started by: nthiruvenkatam
5 Replies

9. Shell Programming and Scripting

Bash shell script: Str(007) to int(7),increment it(8) & convert back to string(008)

Hi, I have the following requirement. There will be following text/line in a file (eg: search-build.txt) PRODUCT_VERSION="V:01.002.007.Build1234" I need to update the incremental build number (eg here 007) every time I give a build through script. I am able to search the string and get... (4 Replies)
Discussion started by: drwatson_droid
4 Replies

10. Shell Programming and Scripting

Bash not equal string comparison

Why does this cause an infinite loop? #!/bin/bash while ]; do echo "$(ipcs | awk '{print $2}')" done echo exit 0 I have verified I eventually get Semaphore so it should break out of the while loop. $ echo $(ipcs | awk '{print $2}') Shared shmid 262145 294914... (6 Replies)
Discussion started by: cokedude
6 Replies
rmvq(9F)						   Kernel Functions for Drivers 						  rmvq(9F)

NAME
rmvq - remove a message from a queue SYNOPSIS
#include <sys/stream.h> void rmvq(queue_t *q, mblk_t *mp); INTERFACE LEVEL
Architecture independent level 1 (DDI/DKI). PARAMETERS
q Queue containing the message to be removed. mp Message to remove. DESCRIPTION
rmvq() removes a message from a queue. A message can be removed from anywhere on a queue. To prevent modules and drivers from having to deal with the internals of message linkage on a queue, either rmvq() or getq(9F) should be used to remove a message from a queue. CONTEXT
rmvq() can be called from user or interrupt context. EXAMPLES
This code fragment illustrates how one may flush one type of message from a queue. In this case, only M_PROTO T_DATA_IND messages are flushed. For each message on the queue, if it is an M_PROTO message (line 8) of type T_DATA_IND (line 10), save a pointer to the next mes- sage (line 11), remove the T_DATA_IND message (line 12) and free it (line 13). Continue with the next message in the list (line 19). 1 mblk_t *mp, *nmp; 2 queue_t *q; 3 union T_primitives *tp; 4 5 /* Insert code here to protect queue and message block */ 6 mp = q->q_first; 7 while (mp) { 8 if (mp->b_datap->db_type == M_PROTO) { 9 tp = (union T_primitives *)mp->b_rptr; 10 if (tp->type == T_DATA_IND) { 11 nmp = mp->b_next; 12 rmvq(q, mp); 13 freemsg(mp); 14 mp = nmp; 15 } else { 16 mp = mp->b_next; 17 } 18 } else { 19 mp = mp->b_next; 20 } 21 } 22 /* End of region that must be protected */ When using rmvq(), you must ensure that the queue and the message block is not modified by another thread at the same time. You can achieve this either by using STREAMS functions or by implementing your own locking. SEE ALSO
freemsg(9F), getq(9F), insq(9F) Writing Device Drivers STREAMS Programming Guide WARNINGS
Make sure that the message mp is linked onto q to avoid a possible system panic. SunOS 5.10 9 Jul 2001 rmvq(9F)
All times are GMT -4. The time now is 03:13 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy