Sponsored Content
Full Discussion: bash script problem
Top Forums Shell Programming and Scripting bash script problem Post 47663 by kduffin on Sunday 15th of February 2004 09:51:42 PM
Old 02-15-2004
Tilde expansion seems to have some oddities surrounding it. Not a satisfying answer, because it doesn't solve the real problem, but this seems to work:

Code:
#!/usr/bin/bash

if [ $(grep -c "^\~\/" /tmp/output) -eq 1 ]
then
   VAR=$(cat /tmp/output | sed -e's/\~//g')
   VAR=$(echo $HOME$VAR)
else
   VAR=$(cat /tmp/output)
fi

mkdir $VAR

Cheers,

Keith
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Bash script argument problem

I'm having problems with bash scripts. If a bash script is called with no arguments, I always get "PHIST=!" as the first argument (i.e. this is what $1 equals). Why? Where does this come from, and how can I fix it? Nothing in the bash man pages refer to this mysterious default argument. (2 Replies)
Discussion started by: sszd
2 Replies

2. Shell Programming and Scripting

Problem in bash script

I have written a script and I get error and I don't understand why. neededParameters=2 numOfParameters=0 correctNum=0 while getopts "s:l:" opt do case "$opt" in s) serviceName= $OPTARG #errorline 1 numOfParameters= $numOfParameters + 1 ;; l) ... (12 Replies)
Discussion started by: programAngel
12 Replies

3. Shell Programming and Scripting

Simple bash script problem

#!/bin/bash cd /media/disk-2 Running ./run.sh it's not changing directory.Why? (6 Replies)
Discussion started by: cola
6 Replies

4. Shell Programming and Scripting

problem using variables in bash script

I am using variable to give the location of the file I am using but I get error. Here is the code: LogFile=/tmp/log.email echo -e "could not close the service - error number $error \n" > $LogFile well this is not all the code but is enough because the problem start when I try to use the... (3 Replies)
Discussion started by: programAngel
3 Replies

5. Shell Programming and Scripting

help with a bash script problem

hi to everyone :) i am new to linux and bash and i am trying to build a bash script, that is quite similar to the well known cmd 'split' ... ;) it is now already "working" ... i can use it like: ./splitfix.sh -v -s 10 foo ./splitfix.sh -s 10 -v foo ./splitfix.sh -s 10 foo ./splitfix.sh -v... (5 Replies)
Discussion started by: drjodo
5 Replies

6. Shell Programming and Scripting

Problem using grep in bash script

When it comes to programing and UNIX, I know just enough to be really really dangerous. I have written a python script to parse through a file that contains ~1 million lines. Depending on whether a certain string is matched, the line is copied into a particular file. For the sake of brevity,... (4 Replies)
Discussion started by: errcricket
4 Replies

7. Shell Programming and Scripting

Problem with Bash Script.

Hi guys! I'm new to the forum and to the Bash coding scene. I have the following code paths=/test/a paths=/test/b keywords=\"*car*\" keywords=\"*food*\" for file in `find paths -type f -ctime -1 -name keywords -print 2>/dev/null` do #.... do stuff here for every $file found... (5 Replies)
Discussion started by: RedSpyder
5 Replies

8. Shell Programming and Scripting

Help with bash script problem

Hi, Below is my bash script: cat run_all.sh if && ; then Number_Count_Program $1.results $2.results > $1.$2.counts else Number_Split_Program $1.results $2.results > $1.$2.split fi After I run the following command: ./run_all.sh A B ./run_all.sh: line 1: Anybody advice to edit... (5 Replies)
Discussion started by: perl_beginner
5 Replies

9. Shell Programming and Scripting

Bash/awk script problem

Hi, I have 100 files containing different values in single column, I want to split those files in two separate files (file2 and file3) based on average value of first column of each file, for those files I am working on the following script #bin/bash for memb in $(seq 1 100) do awk... (4 Replies)
Discussion started by: dsp80
4 Replies

10. UNIX for Beginners Questions & Answers

Array problem in Bash Script

I am trying to write a Bash Script using a couple of arrays. I need to perform a countdown of sorts on an array done once daily, but each day would start with the numbers from the previous day. This is what I'm starting with : #!/bin/bash days=(9 8 7 6 5) for (( i = 0 ; i < ${#days} ; i++... (4 Replies)
Discussion started by: cogiz
4 Replies
SYSPROFILE(8)						      System Manager's Manual						     SYSPROFILE(8)

NAME
sysprofile - modular centralized shell configuration DESCRIPTION
sysprofile is a generic approach to configure shell settings in a modular and centralized way mostly aimed at avoiding work for lazy sysad- mins. It has only been tested to work with the bash shell. It basically consists of the small /etc/sysprofile shell script which invokes other small shell scripts having a .bash suffix which are contained in the /etc/sysprofile.d/ directory. The system administrator can drop in any script he wants without any naming convention other than that the scripts need to have a .bash suffix to enable automagic sourcing by /etc/sysprofile. This mechanism is set up by inserting a small shell routine into /etc/profile for login shells and optionally into /etc/bashrc and/or /etc/bash.bashrc for non-login shells from where the actual /etc/sysprofile script is invoked: if [ -f /etc/sysprofile ]; then . /etc/sysprofile fi For using "sysprofile" under X11, one can source it in a similar way from /etc/X11/Xsession or your X display manager's Xsession file to provide the same shell environment as under the console in X11. See the example files in /usr/share/doc/sysprofile/ for illustration. For usage of terminal emulators with a non-login bash shell under X11, take care to enable sysprofile via /etc/bash.bashrc. If not set this way, your terminal emulators won't come up with the environment defined by the scripts in /etc/sysprofile.d/. Users not wanting /etc/sysprofile to be sourced for their environment can easily disable it's automatic mechanism. It can be disabled by simply creating an empty file called $HOME/.nosysprofile in the user's home directory using e.g. the touch(1) command. Any single configuration file in /etc/sysprofile.d/ can be overridden by any user by creating a private $HOME/.sysprofile.d/ directory which may contain a user's own version of any configuration file to be sourced instead of the system default. It's names have just to match exactly the system's default /etc/sysprofile.d/ configuration files. Empty versions of these files contained in the $HOME/.syspro- file.d/ directory automatically disable sourcing of the system wide version. Naturally, users can add and include their own private script inventions to be automagically executed by /etc/sysprofile at login time. OPTIONS
There are no options other than those dictated by shell conventions. Anything is defined within the configuration scripts themselves. SEE ALSO
The README files and configuration examples contained in /etc/sysprofile.d/ and the manual pages bash(1), xdm(1x), xdm.options(5), and wdm(1x). Recommended further reading is everything related with shell programming. If you need a similar mechanism for executing code at logout time check out the related package syslogout(8) which is a very close compan- ion to sysprofile. BUGS
sysprofile in its current form is mainly restricted to bash(1) syntax. In fact it is actually a rather embarrassing quick and dirty hack than anything else - but it works. It serves the practical need to enable a centralized bash configuration until something better becomes available. Your constructive criticism in making this into something better" is very welcome. Before i forget to mention it: we take patches... ;-) AUTHOR
sysprofile was developed by Paul Seelig <pseelig@debian.org> specifically for the Debian GNU/Linux system. Feel free to port it to and use it anywhere else under the conditions of either the GNU public license or the BSD license or both. Better yet, please help to make it into something more worthwhile than it currently is. SYSPROFILE(8)
All times are GMT -4. The time now is 07:35 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy