Sponsored Content
Top Forums Shell Programming and Scripting Sed: would like to return an error for empty string Post 303045788 by RudiC on Monday 13th of April 2020 09:17:42 AM
Old 04-13-2020
Try testing for "start-of-line nothing end-of-line":

Code:
echo "" | sed -n -r '/[0-9]{3}/{q100}; /^$/{q200}'; echo $?
200

And, wouldn't it make sense to have different codes for different errors?
This User Gave Thanks to RudiC For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to check for null or empty string

Hi, I need to check for value not equal (<>) to 21 and not equal empty or null values. Please modify this script if then echo "$VALUE,$BSC_NAME,$BSC_ID" > $OUT_FILE/power_up.out end if TQ (5 Replies)
Discussion started by: doer
5 Replies

2. Shell Programming and Scripting

Check for empty string

Hello All, I have written shell script whcih at the max 3 parameters. When only one commandline argument and other two command line arguments are passed as empty string like eg : archive ' ' ' ' Then i need to check whether the commandline... (12 Replies)
Discussion started by: rahman_riyaz
12 Replies

3. UNIX for Dummies Questions & Answers

to check if file is empty or not and return a non zero value

Hi All, I am new to unix worldd . I need to check a file1 if its empty or not. If its empty then return a non zero value say 99 could you pls let me know the perl script for this. (2 Replies)
Discussion started by: mavesum
2 Replies

4. Shell Programming and Scripting

Need Help to deal with empty string

Hi one to All i have written the code for searching the string in the file for specified path. its working fine, but my req:if the string is not available in the file , it should display the Message saying that , string is not available in the file. code is: echo "give the path where... (12 Replies)
Discussion started by: saic
12 Replies

5. Shell Programming and Scripting

error while replacing a string by new line character in sed

hi, when i am doing the following things getting error Can anyone please suggest i have a file where there is a line like the following branch=dev sdf dev jin kilii fin kale boyle dev james dev i want to search the existance of dev in the above line. cat "$file" | sed -n... (8 Replies)
Discussion started by: millan
8 Replies

6. Shell Programming and Scripting

sed or awk command to replace a string pattern with another string based on position of this string

here is what i want to achieve... consider a file contains below contents. the file size is large about 60mb cat dump.sql INSERT INTO `table1` (`id`, `action`, `date`, `descrip`, `lastModified`) VALUES (1,'Change','2011-05-05 00:00:00','Account Updated','2012-02-10... (10 Replies)
Discussion started by: vivek d r
10 Replies

7. Programming

Checking not empty string

I have a string s Are the following equivalent? if ( ! s.empty() ) { } if ( s ) { } (1 Reply)
Discussion started by: kristinu
1 Replies

8. Shell Programming and Scripting

Check if the string is empty

I am reading from a file and executing the jobs with/without parameters as the job requires. File job1 R job2 job3 Y 123 if then <job>.ksh else <job>.ksh $params fi This works fine if the line read from the file has parameters it executes like job1.ksh R But for... (2 Replies)
Discussion started by: nw2unx123
2 Replies

9. Shell Programming and Scripting

Unzipping the empty file sends a non Zero return code

Hi, I have a shell script where I am trying to unzip bunch of files zip files one by one. But out of many zip files, if any one zip file is empty, the unzip command sends a non-zero return code and fails the script. I am trying to see if I can get a success error code even if the script... (2 Replies)
Discussion started by: Saanvi1
2 Replies

10. Shell Programming and Scripting

Cant check empty string

Hello So i have that script collection, in which i have a single script to create a configuration file. In there, i have multiple occourences of something like this: prj_title=$(tui-read "What is the TITLE? ($prj_name):") ] && prj_title="${prj_name/_/ }" They all work as expected, if... (5 Replies)
Discussion started by: sea
5 Replies
I18N::LangTags::Detect(3pm)				 Perl Programmers Reference Guide			       I18N::LangTags::Detect(3pm)

NAME
I18N::LangTags::Detect - detect the user's language preferences SYNOPSIS
use I18N::LangTags::Detect; my @user_wants = I18N::LangTags::Detect::detect(); DESCRIPTION
It is a common problem to want to detect what language(s) the user would prefer output in. FUNCTIONS
This module defines one public function, "I18N::LangTags::Detect::detect()". This function is not exported (nor is even exportable), and it takes no parameters. In scalar context, the function returns the most preferred language tag (or undef if no preference was seen). In list context (which is usually what you want), the function returns a (possibly empty) list of language tags representing (best first) what languages the user apparently would accept output in. You will probably want to pass the output of this through "I18N::LangTags::implicate_supers_tightly(...)" or "I18N::LangTags::implicate_supers(...)", like so: my @languages = I18N::LangTags::implicate_supers_tightly( I18N::LangTags::Detect::detect() ); ENVIRONMENT
This module looks for several environment variables, including REQUEST_METHOD, HTTP_ACCEPT_LANGUAGE, LANGUAGE, LC_ALL, LC_MESSAGES, and LANG. It will also use the Win32::Locale module, if it's installed. SEE ALSO
I18N::LangTags, Win32::Locale, Locale::Maketext. (This module's core code started out as a routine in Locale::Maketext; but I moved it here once I realized it was more generally useful.) COPYRIGHT
Copyright (c) 1998-2004 Sean M. Burke. All rights reserved. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The programs and documentation in this dist are distributed in the hope that they will be useful, but without any warranty; without even the implied warranty of merchantability or fitness for a particular purpose. AUTHOR
Sean M. Burke "sburke@cpan.org" perl v5.16.2 2012-10-11 I18N::LangTags::Detect(3pm)
All times are GMT -4. The time now is 05:24 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy