LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Blogs
User Name
Password

Notices

Old

[bash] "keep trying" command, even if exits with error, for at least 10 times

Posted 08-08-2014 at 10:40 PM by the dsc (linux-related notes)
Updated 08-08-2014 at 10:42 PM by the dsc
Tags bash

A script that tries to run a given arbitrary command N times, or until it exits with success. The commented parts are aborted attempts to make it figure whether the first parameter is a number instead of a command, and that would be used as the maximum number of attempts. Something went wrong, sometime I'll try to figure it out.

Quote:
#!/bin/bash
#input="$@"
# this program is stupid. It's declared to be in public domain by its author, who whishes to remain anonymous
...
Member
Posted in Uncategorized
Views 89 Comments 2 the dsc is offline
Old

Give a default/non-null value in order to avoid the "unary operator expected" error

Posted 02-19-2014 at 03:00 PM by the dsc (linux-related notes)
Tags bash

Quote:
Originally Posted by cfajohnson
Quote:
i am trying to compare a value with value 50. but i am getting
"[: -lt: unary operator expected"

I am using

if [ $j -lt 50 ]
then
echo "------------"

fi
Make sure that $j expands to a value. Best is to set it explicitly, but you can also give it a default value (0 in this example):


Code:
if [ ${j:-0} -lt 50 ]
http://www.unix.com/302295072-post3.html...
Member
Posted in Uncategorized
Views 262 Comments 0 the dsc is offline
Old

Bash Scripting for Dummies and Geniuses

Posted 11-20-2013 at 09:18 AM by rtmistler
Updated 06-17-2014 at 01:25 PM by rtmistler

One only need look at LinuxQuestions.org to notice the great amount of script (and code) questions and varieties of comments to realize that we all have varying opinions about bash programming.

Many questions are very complicated, as are the resulting answers and script recommendations. I've noticed that two fundamental points are invariably overlooked by the questioners, and many of the comments:

Quote:
"All programming is the use of simple operations to solve complex
...
Senior Member
Posted in Bash Scripting
Views 237 Comments 3 rtmistler is offline
Old

Run C/C++ Code As Script

Posted 09-04-2013 at 11:36 AM by rainbowsally
Updated 08-06-2014 at 07:13 AM by rainbowsally (new version)

runc update Sept 27, 2013

http://rainbowsally.org/rainbowsally...-rs-1.2.tar.gz

Changes slist_count() to standard objlist syntax and removes slist_getCount()
Removes destructor functions from objlist so that each class explicitly free anything memory they allocate.
Added atexit() function to tmpmem/tmpstr functions.
Most of these changes address memory leaks and/or memory that remains accessible after the apps close.

--------------...
Member
Posted in Uncategorized
Views 363 Comments 0 rainbowsally is offline
Old

bash read file

Posted 05-24-2013 at 09:20 AM by NullTerminator
Updated 05-24-2013 at 11:26 AM by NullTerminator

Sample of while loop to process input
Code:
#!/bin/sh
##################################
# Purpose: Cleanup any confirmation reports (*.pdf) older than xx days
# Called By:  batch daily cleanup process,  /Applications/xyz/distributor.sh
# Author: jeb
# Date: 4/20/07
# Comments: The while loop is preferred over the find -exec rm {} syntax because it
#           does not spawn a process for each file to be deleted.
#           The script expects
...
LQ Newbie
Posted in Uncategorized
Views 542 Comments 0 NullTerminator is offline

  



All times are GMT -5. The time now is 06:13 PM.

Main Menu
Advertisement

My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration