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

Notices

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 142 Comments 0 the dsc is offline
Old

Run C/C++ Code As Script

Posted 09-04-2013 at 11:36 AM by rainbowsally
Updated 09-27-2013 at 03:55 PM by rainbowsally (new version)

runc update Sept 27, 2013

http://rainbowsally.net/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 265 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 469 Comments 0 NullTerminator is offline
Old

A good $PS1 for displaying long paths in the bash prompt

Posted 03-13-2013 at 11:29 PM by the dsc (linux-related notes)
Updated 03-13-2013 at 11:30 PM by the dsc
Tags bash, prompt, ps1

Code:
PS1='${debian_chroot:+($debian_chroot)}\t \u $(if [ ${#PWD} -gt 30 ] ; then myPWD="${PWD:0:12}…/\W" ; myPWD="${myPWD:0:25}…" ; else myPWD=$PWD; fi ; echo $myPWD) $ '
It will display full paths smaller than 30 characters entirely, but for longer paths it will get only the first characters of the whole path, and the fist characters of the last folder in the full path.

The end result is something like:

HH:MM:SS tuxguy /home/tuxguy/mystuf.../xmas...
Member
Posted in Uncategorized
Views 576 Comments 0 the dsc is offline
Old

PlayShell 0.2-WP13

Posted 01-08-2013 at 03:17 AM by konsolebox
Updated 01-08-2013 at 03:36 AM by konsolebox

PlayShell 0.2-WP13 was released today.

Hompepage: http://playshell.sourceforge.net/
SF.net summary page: http://sourceforge.net/projects/playshell
Release files: http://sourceforge.net/projects/play...Shell/0.2-WP13
Online repository: http://sourceforge.net/p/playshell/code/
Senior Member
Posted in Projects
Views 449 Comments 0 konsolebox is offline

  



All times are GMT -5. The time now is 12:09 AM.

Main Menu

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