Even though the idea "might" not be great I still wrote this piece of code to get practice.. Which means that it is the CODE that matters here.
Anyways;
The intension is to create a program(or do we call it script?) that searches recursively through a folder to find a file - stored in a folder - and then allocate an environment variable for this specific location which is given the name of the folder itself.
Errrh
In other words, the folder /home/myusername/bash/myscript/ would get an environment variable called 'myscript' with the value '/home/myusername/bash/myscript/' ...if it has a file whose name is stored in $CREATE_VAR_OK
Here's the code that doesn't work though:
($CREATE_VAR_OK is ".CREATE_LINK" which is a file put in all the folders I want to create a variable for)
If I add "env" in the case check (; env; ) it displays the variable located in the environment. However if I run env AFTER the script has been run it seems to be gone...
I might also add that the piece of code listed is in a FUNCTION. I chose not to put the entire piece of code out there now since I have some lazy coding that I'd like to hide unless I have to show
...The echo statement does also give out the correct name of the folder.
Hope this makes some sense..!
(extra question: is there anyways of avoiding to use ls here to view hidden files?)
Last edited by Franklin52; 05-04-2010 at 04:32 AM..
Reason: Please use code tags!
Given the following piece of code put in a shell function..
...Is there anyone who knows why my variable given the name ${PWD##*/} won't be extracted to the environment as long as the shell runs, but only during the runtime of the script?
.. (A)
Last edited by Franklin52; 05-04-2010 at 04:33 AM..
Reason: Please use code tags!
From the man page of bash:
If I understood you right you expected to have that variable available in the environment/shell where you started the script from. This not the case since this shell is not a child of that script.
Hi guys
I'm running on debian on a small embedded system. I have a ppp interface that is connected to the internet (and works). My unit also has wifi access point (which works and I can connect to it).
I want to allow connections to the wifi to be able to use the internet from ppp0... (1 Reply)
Hello,
Images won't work on UNIX when I try posting them on my website I'm working on. It doesn't show the image, and it's simply erroring.
Help! Thanks! (5 Replies)
Hi! I'm sure that somebody here installed freeBSD from a download of a virtual disc (.iso). But I made 5 downloads of 5 differents freeBSD installation (and no one has worked).Can somebody tell me where to download and how (if needed) to prepare the cd? (8 Replies)
#!/usr/bin/ksh
set -x
testfile=my.test.file.flag
echo ${testfile: (-4)}
#/home/maldohe/scripts/spawn1&
sleep 3
echo myspawn is now ending
exit
Background:
I am trying to extract the word flag from anf given file name. This is a demo script that I am working on to fix a production issue.... (8 Replies)
I just installed a fork of opensolaris, and I really like it.
I would hate going back to Ubuntu, But one issue, I cannot get my Dell Wireless 1450 Wireless USB Adapter working.
On Ubuntu 10.4 I just installed nonfree firmware, but I guess it doesn't work that way on Solaris, any help would be... (5 Replies)
I am new to unix and therefore I did a lot of reading before posting. So please, if this has been answered before, forgive me for re-posting and point me to the right place for the answer. I have spent many hours searching the net and read over 50 posts in this forum and even tried a few thing but... (20 Replies)
I typed:
echo "echo hi > at_log.txt" | at now +1minute
to test the at command on my terminal. I got the message:
job 8 at Thu Feb 25 18:42:00 2010
I waited for a minute but nothing happened. I tried listing at_log.txt, but it said there was no such file. Am I doing something... (2 Replies)
Hi All,
can anybody tell me what's wrong with this code?
# SEARCH replaced by REPLACE
#!/bin/bash
SEARCH="95$$ 0 t"
REPLACE="95$$ 1 t"
for I in `ls *000.inp | cut -c-12`;
do
echo $I
sed 's/$SEARCH/$REPLACE/' ${I}-000.inp > ${I}-100.inp
done
It don't replace the string... (5 Replies)
I'm trying to figure out why this if statement won't work:
if || $zipcount != 6 ]]
then
echo ${myline}
echo "ZIPCODE WARNING! ${zipcode} ${zipcount}"
fi
if ]]
then
echo ${myline}
echo "STATE WARNING!... (3 Replies)
hey programmers!
1-why won't gcc accept as an argument? i tried the recommendations on the man page of getch(),..etc. nothing worked.
2-why it won't see <iostream> && <fstream> even if i implemented the function as follow
std::cout<<"..etc"<<endl;
3-after i type this code in it gives... (6 Replies)