Sponsored Content
Top Forums Shell Programming and Scripting [BASH] recognise new line regex in case statement Post 302359023 by Scrutinizer on Monday 5th of October 2009 03:27:29 PM
Old 10-05-2009
Hi ASGR,

You can use "" for an empty line:
Code:
while read line; do
  case $line in
    ""|\#* ) : ;;
    \[*\]  ) do_label;;
    *      ) do_error;;
  esac
done < $filename

S.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

anchoring regex using case and ksh

Outside this process I built a file containing snmp response filtering for hostname, model type and ios version. I want to get a count across the network of those devices running 11.x code, 12.0 mainline, 12.0 T train and above, 12.1 and above and OS levels. This works ok .. but its cheap... (2 Replies)
Discussion started by: popeye
2 Replies

2. Shell Programming and Scripting

bash regex =~ case insensetive, possible?

It can get very annoying that bash regex =~ is case-sensetive, is there a way to set it to be case-insensetive? if ]; then echo match else echo no match fi (8 Replies)
Discussion started by: TehOne
8 Replies

3. Shell Programming and Scripting

bash case statement output help

greetings, I have a script that is taking input like this: a b c d aa bb aaa bbb ccc ddd and formating it to be like this: a b c d aa bb aaa bbb ccc ddd (4 Replies)
Discussion started by: adambot
4 Replies

4. Shell Programming and Scripting

Can you use logical operators in a case statement (bash)?

I'm pretty sure I already know the answer to this, but I want to make sure I'm not overlooking anything. I'm working on a log monitoring script and every 10 lines I want to display a summary of events. The thing is, there are a lot of possible events, that likely won't have happened, so I only want... (0 Replies)
Discussion started by: DeCoTwc
0 Replies

5. Shell Programming and Scripting

Problem using bash case statement

I have the following bash script and it is not accepting the lines "--"|"--""-") "--""-"") while do echo "Current Argument is ${1}" case "$1" in "--"|"--""-") echo "Argument is ${1}" shift # Skip ahead one to the next argument. ... (1 Reply)
Discussion started by: kristinu
1 Replies

6. Shell Programming and Scripting

Bash case Statement and Using Line Anchors?

Hello All, I am writing a script that is to be placed on multiple servers, and of course I've started running into some compatibility issues for certain shell commands. The code below worked just fine on most of my machines except for a couple. Here I had 4 separate lines in my script that... (3 Replies)
Discussion started by: mrm5102
3 Replies

7. Shell Programming and Scripting

Question about REGEX Patterns and Case Sensitivity?

Hello All, I'm in the middle of a script and I'm doing some checks with REGEX (i.e. using the '"shopt -s nocasematch" that at least the first one should print "FALSE" but it prints "TRUE"..? For Example: #!/bin/bash MY_VAR="HELLO" ### This prints "TRUE" PATTERN_1="^*" if ] then... (5 Replies)
Discussion started by: mrm5102
5 Replies

8. Programming

Passing arguments from command line to switch case statement in C

Hi Am pretty new to C.. Am trying to pass the arguments from command line and use them in switch case statement.. i have tried the following #include <stdlib.h> main(int argc, char* argv) { int num=0; if ( argc == 2 ) num = argv; printf("%d is the num value",num); switch ( num ) ... (2 Replies)
Discussion started by: Priya Amaresh
2 Replies

9. Shell Programming and Scripting

BASH - case statement

Hi Gurus, I have the below BASH code which does not works for upper case alphabets except Z (upper case Z). What may be the reason. Also escape sequences like \n, \t, \b, \033(1m \033(0m (For bold letter) are not working. case $var in ) echo "Lower case alphabet" ;; ... (7 Replies)
Discussion started by: GaneshAnanth
7 Replies

10. Shell Programming and Scripting

Bash read input in case statement not working as expected

I'm having an issue with bash read input when using a case statement. The script halts and doesn't read the input on the first loop. if I hit enter then the scripts starts to respond as expected. Need some help here. defaultans=8hrs read -e -i $defaultans -p "${bldwht}How long would you like... (5 Replies)
Discussion started by: woodson2
5 Replies
SOCKATMARK(3)						   BSD Library Functions Manual 					     SOCKATMARK(3)

NAME
sockatmark -- determine whether the read pointer is at the OOB mark LIBRARY
Standard C Library (libc, -lc) SYNOPSIS
#include <sys/socket.h> int sockatmark(int s); DESCRIPTION
To find out if the read pointer is currently pointing at the mark in the data stream, the sockatmark() function is provided. If sockatmark() returns 1, the next read will return data after the mark. Otherwise (assuming out of band data has arrived), the next read will provide data sent by the client prior to transmission of the out of band signal. The routine used in the remote login process to flush output on receipt of an interrupt or quit signal is shown below. It reads the normal data up to the mark (to discard it), then reads the out-of-band byte. #include <sys/socket.h> ... oob() { int out = FWRITE, mark; char waste[BUFSIZ]; /* flush local terminal output */ ioctl(1, TIOCFLUSH, (char *)&out); for (;;) { if ((mark = sockatmark(rem)) < 0) { perror("sockatmark"); break; } if (mark) break; (void) read(rem, waste, sizeof (waste)); } if (recv(rem, &mark, 1, MSG_OOB) < 0) { perror("recv"); ... } ... } RETURN VALUES
Upon successful completion, the sockatmark() function returns the value 1 if the read pointer is pointing at the OOB mark, 0 if it is not. Otherwise, the value -1 is returned and the global variable errno is set to indicate the error. ERRORS
The sockatmark() call fails if: [EBADF] The s argument is not a valid descriptor. [ENOTTY] The s argument is a descriptor for a file, not a socket. SEE ALSO
recv(2), send(2) HISTORY
The sockatmark() function was introduced by IEEE Std 1003.1-2001 (``POSIX.1''), to standardize the historical SIOCATMARK ioctl(2). The ENOTTY error instead of the usual ENOTSOCK is to match the historical behavior of SIOCATMARK. BSD
October 13, 2002 BSD
All times are GMT -4. The time now is 09:01 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy