Ubuntu :: Curly Brace Expansions Don't Work In Bash Scripts?

Jul 20, 2010

I'm trying to use a curly brace expansion in a Bash script, but it's not working for me in Ubuntu. It works in other distributions, like Arch, Fedora and Debian, and it works in Ubuntu as well, but only from the command line, not in a Bash script. I've tried it on multiple Ubuntu (10.04) machines, so it's not specific to one configuration. Here's what I did:

Code:
mkdir a b
Now this works:

[code]....

View 3 Replies


ADVERTISEMENT

Software :: Bash - Brace Expansion Using Variable?

Mar 24, 2010

I'm trying to use brace expansion on a string, but I can't seem to get it working with variable substitution:

Code:

$ cat script.sh
#!/bin/bash
echo {1,2,3} # 1.
VAR=1,2,3

[code]....

I've searched google, tldp.org and these forums and I can't seem to find an example of how this would work. I want #2 to work like #1. Any suggestions?

**Edit: I forgot to add, the values in VAR are not sequential and can have multiple digits. For example, VAR=13,17,10.

**Edit2: [URL] The bottom line of code in the first gray block of code shows that you cannot use variables in such an expansion:

Code:

#!/bin/bash
a=1
b=5
echo {$a..$b}

But I'm looking for pasting the complete contents of a variable into these braces, not some portion of it...

View 2 Replies View Related

Ubuntu :: Shell Curly Braces With Double Quotes Does Not Expand As Expect?

Jan 13, 2011

I'm really new here this is the first try to get some knowledge here.I have a littele question."echo {1,2}" does expands 1 and 2.so does "echo "`echo {1,2}`"".But when I do it with double quotes which is "echo "{1,2}"" it doesn't expand at all.why does this happen? I have read man for bash but could not get any clue.

Yuki
Code: -- the output i see --
sh-3.2# echo {1,2}

[code]...

View 3 Replies View Related

Fedora Security :: SELinux Macro Expansions Generating Numbers?

Mar 28, 2009

I have gotten over my inability to add SELinux users and am trying to write an SELinux module on my Fedora 10 machine, standard SELinux distribution. Most of it works just fine, but I've been having strange troubles with some policy interfaces--m4 expands them to numbers rather than valid SELinux policy language. Here's what I'm getting:

seutil_read_config($1_t) ---> 679
seutil_read_src_policy($1_t) ---> 1021
files_search_etc($1_t) ---> 1875

As far as I know all of these are valid policy interfaces (I've checked them up in their respective files, and they do exist and contain what appears to be valid policy). The last one I know because I went into seutil_read_src_policy and put its contents into the module rather than the macro itself. Now, I could do the same with files_search_etc, but really I'd like the top-level macro to just work. Does anyone know what is causing this problem? I'm certain I'm using correct syntax, unless there's a whitespace rule I'm not familiar with.

A secondary problem I have, generating warnings rather than errors, is that for some reason ' s are popping up in my expanded module, right after the end of expansions of some (but not all) macros that I've defined.

View 2 Replies View Related

Programming :: Using Brace Expansion With Find?

Jun 2, 2011

I am interested in a more flexible targeted search in my directories. For example, if I am searching for all .txt .dat and .bat files (then perform an operation), I would think that the following would work:

find . -name '*.{txt,dat,bat}' -exec ...

But I get no results. I am running on Cygwin.I have confirmed that:

find . -name '*.txt' -exec ...
find . -name '*.dat' -exec ...
find . -name '*.bat' -exec ...

all find the aforementioned files. But, find . -name '*.{txt}'still produces no output.

View 7 Replies View Related

General :: How To Do Auto Brace In Emacs

Apr 19, 2010

If i type '{' and hit Enter emacs will automatically put '}'. How can i do this?

View 3 Replies View Related

Programming :: [C++] Error: Array Must Be Initialized With A Brace-enclosed Initializer

Jun 29, 2011

I'm implementing exceptions using longjmp() (since C++ exceptions don't offer the features that I need, including resuming and a "finally" block), like this:

Code:

jmp_buf ex_jmpbuf;
void *ex_exception;
bool ex_resumable;
jmp_buf ex_resumebuf;

[code]....

Why are the curly braces being misinterpreted as arrays here, but not anywhere else?

View 11 Replies View Related

Ubuntu :: Bash: How To Make ${var%% *} Work

May 1, 2011

bash: how do you make the construct ${var%% *} work? I am trying to select the first word from a variable which contains many space-separated words. I am running Ubuntu 10.10 with GNU bash, version 4.1.5(1)-release (x86_64-pc-linux-gnu) and when I try to use this construct, the expression returns the complete variable with no removal of trailing anything.

View 3 Replies View Related

Ubuntu :: Why Doesnt This Bash Command Work?

Apr 8, 2010

cd /Desktop/ ??

I can change to just about any dir of my file system with cd /filename/

eg cd /var/ or cd /opt/

it will skip me up or down the tree to get there but when if go cd /Desktop/or cd /myuseraccount/

is get: bash: cd: /Desktop/: No such file or directory

i have to be right next to the directory to get there.i dont get it. why is this?

View 6 Replies View Related

Ubuntu :: Bash Sudo Scripts Fail To Work After Install Of 10.04

Aug 4, 2010

I had some bash scripts on Ubuntu 09.10 (mint version) that fail to work on Ubuntu 10.04. The line that fails is the following:

Code: # cat file_with_my-password.txt > sudo -S something cat: invalid option -- 'S' Try `cat --help' for more information. In my case "something" mounts some filesystems (that fail to load from fstab - bios "fake" raid 10), but I get the same error for any sudo command. It is the same script that used to work under 09.04 :-/

View 2 Replies View Related

Programming :: Bash - Renaming Files Won't Work

Apr 1, 2010

I'm trying to rename a lot of files getting rid of the space on the names. For that purpose I wrote this very simple bash script, but for some reason is not working.

Code:
for i in "$(ls)"
do
j=$(echo "$i" | sed 's/ /_/g')
mv "$i" "$j"

done But what I get in return for each line is just one long file name with all the file names concatenated. I've tried with echo -e "$i" as well with no results. This has to be something really simple that I'm missing but I just can't see it.

View 11 Replies View Related

Software :: Make Ctrl + Backspace Work In Bash?

Jan 18, 2010

I've tried without luck to get ctrl-backspace working to delete the previous word in bash. I edited my .inputrc and tried the following:

"C-": unix-word-rubout
Control-Rubout: unix-word-rubout

I can make it work if I change it to some other sequence (Control-j: unix-word-rubout makes ^j erase the word), but I can't make it work with backspace.

View 6 Replies View Related

Programming :: Bash: String Verifier Doesn't Work

May 26, 2011

I'm currently learning bash programming and am trying to create a program to maintain a list of people. Here is the code so far:

Code:

#!/bin/bash
# Namelist
clear

[code]....

As you can see, I attempted to build in a protective measure to prevent duplicate entries using "if grep -Fxq "$FN $LN" /home/andrea/namelist.txt", FN and LN being first name and last name as you can see in the first read operation. However, this fails to actually work. Demonstrations:

[URL]

It saves the details to the file rather than displaying the error message, or in other words, it doesnt check the file properly.

View 4 Replies View Related

Fedora :: Bind C-u To Kill-whole-line In Bash Doesn't Work

Mar 19, 2010

I'd like control-u to erase the whole line, instead of only erasing backwards from the current point. I tried

bind -r "C-u"
bind -r C-u
bind -r ^U

to erase the current binding for control-u, but after running any / all of the above, bind -p still tells me

"C-u": unix-line-discard

bind "C-u":kill-whole-line doesn't work either. How can I change the binding of control-u to kill-whole-line?

View 2 Replies View Related

Programming :: Auto_extract.sh Bash Script - Does Not Work With Any Paths That Contain Spaces

Jan 25, 2011

Have worked with Linux at home for some time and have wrote the below script.

This script is run when a .torrent file finishes downloading and extracts any .rar files into an extracted directory.

However there are 2 thing that i cannot for the life of me get working.

These are:

1. I need the script to check a txt file to see if the file has been extracted previously.

2. The script does not work with any paths that contain spaces.

Code:

View 11 Replies View Related

Programming :: Command Line Works - Won't Work From Inside Bash Script

Feb 16, 2011

Writing script to create backup of file by adding datetime to file name. Basically test for file presence if there, cp with datetime then rm original cp works fine from command line but get cannot stat `full path to file': No such file or directory

Code:

Here are the errors: cp: cannot stat `~/html/CVP_dadamail/.dada_files/.logs/errors.txt': No such file or directory rm: cannot remove `...': No such file or directory

The for statement is a placeholder as I have same file to backup out of several directories. using "bash -x scriptname" -OR- inserting echos, I can see I've constructed the strings properly. Believing it might be related to the hidden directories, I tried setting the shopt "glob" options to no avail.

Ultimately I'll add the other directories to the for loop and then run this from a cron job, so if you see potential pitfalls knowing I'm headed in that direction...believe construct would be

Code:

View 4 Replies View Related

Software :: Dpkg - Add / Remove Package Won't Work - Terminal Goes: Bash Syntax Error Near Unexpected Token `newline'

Mar 11, 2010

When I am adding removing packages to get more hard drive space, this is not the first time I left too many pages open and it crashes on me. My son would fix it by typing in the terminal sudo something, but I want to know how to do this. The only thing not working is the add/remove packages at the moment. Here is what it said, E:dpkg was interrupted you must manually run 'dpkg--configure -a' to correct the problem E: _cache-open()failed please report. Please, could someone tell me how to get the default back or whatever. When I type in the terminal, it refused my password until I tried several times, plus, it finally says in the terminal No such command. Bash. No such command. I am hoping this question is one you do recognize the answer for.

I tried using Yum to remove the package. Like this:

To remove or uninstall a package:

Code:

yum -y remove ,package name>

Terminal goes: Bash syntax error near unexpected token `newline'

View 3 Replies View Related

General :: Why Does Running A Program In Bash Work, When Running It In The Menu Doesn't?

Jul 26, 2010

I presume there is something in the JWM window manager - or Puppy Linux Lupu 5.01 itself that is conflicting with the normal loading of GMPLAYER....

I would like to know how to troubleshoot, and fix this problem if possible (even a workaround would be great).

View 1 Replies View Related

Programming :: CURL In Bash - Error "Upload Is Disabled During Short Maintenance Work (ETA 10 Minutes). Brb"

Mar 7, 2010

i'm trying to write a bash script to upload an image to [URL], but i can't get i working properly. Everytime i try, the html returns me a error saying "Upload is disabled during short maintenance work (ETA 10 minutes). Brb!", while from the browser everything works fine. This is my current command line:

Code: curl -L -b cookie-pix.txt -c newcookie.txt www.pixhost.org/cover-upload -A "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)" -F 0=@/home/admin/Desktop/karm.jpg -F content_type=0 -F press=Upload And this is the html of the form:

[Code]....

View 1 Replies View Related

Ubuntu :: Terminal Bash / -bash: Ls: Command Not Found

Jun 5, 2011

I got a problem with terminal, since i'm really a noob with terminal i don't know how to fix it.Everytime i type in a command it shows for example:

-bash: ls: command not found

Even the basic commands don't work... just cd <directory> and those things works

View 9 Replies View Related

Programming :: Bash: Printing The Line Number In Bash Script?

Feb 4, 2011

I would like to know how do I print the line # in a script. My requirement is, I have a script which is about ~5000 lines long. If there are any errors happen I just exit. And I would like to add the line # of the script where the error happened.

View 3 Replies View Related

General :: Write A Literal Bash Command In A Bash File?

Nov 29, 2010

I create a bash script that writes another bash file. But in the generated bash file I want to write a bash command in the file and not executing it.Here's my bash file:

Code:
#!/bin/bash
cat > ~/generateGridmix2data.sh << END

[code]...

View 6 Replies View Related

General :: Running Bash But Common Bash Commands Not Working?

Jul 17, 2010

below are the details of my system. I have bash as my current shell, some really common commands aren't working.

Do I need to do a re-installation of bash? Or how do I install a selection of bash commands which I need? (for example a subset of [URL])

Code:
root@sdptfw:~ # uname -a
Linux sdptfw.sdpt.co.za 2.4.36 #1 Tue Jul 22 13:13:24 GMT 2008 i686 i686 i386 GNU/Linux
root@sdptfw:~ # echo $SHELL$
/bin/bash$

[Code]....

View 13 Replies View Related

Programming :: Bash Ctrl+c Tarp And Bash Read With Timeout?

Jan 24, 2010

simple bash code:

Code:
#!/bin/bash
trap "echo 'you got me'" SIGINT SIGTERM # to trap ctrl+c
echo "Press ctrl+c during 5 sec loop"
for ((i=0;i<5;i++)); do

[Code]...

How come code behaves normally and stops when ctrl+c signal is caught and resumes, but after I use at least one timeout read in the code it looks like, if signal is caught again it doesn't pause the execution but skips the loop. If you remove -t (timeout) option from the read, both loops look the same!

View 10 Replies View Related

Programming :: Reading A Bash Variable In Bash Scripting ?

Nov 26, 2008

I have a config file that contains:

my.config:

Code:

Now in my bash script, I want to get the output /home/user instead of $HOME once read. So far, I have managed to get the $HOME variable but I can't get it to echo the variable. All I get is the output $HOME.

Here is my parse_cmd script:

Code:

View 3 Replies View Related

Programming :: Run Multiple Bash And Php Scripts From A Bash Script?

Jul 25, 2011

I have written quite a few separate bash & scripts and php scripts that up to now I have run from cron jobs. However I have to estimate how long each takes to run, before running the next and so it probably takes much longer than necessary to run them all. They have to run in order.

Now there are so many I am thinking it would be better to have a master bash script that would run one after the other, but I am not sure how to get the master script to wait before starting to run the next script. Is this possible and is there a command that will make the script wait between bash and php scripts , for them to finish, before running the next?

View 5 Replies View Related

Slackware :: Bash - Random Headers When Starting Bash In X?

Jan 13, 2011

I have searched and searched and maybe I don't know how to articulate this issue with out just posting the problem I'm having. Every time I bring up a terminal window I get the following "Header"

declare -x COLORTERM="gnome-terminal"
declare -x CPLUS_INCLUDE_PATH="/usr/lib64/qt/include"
declare -x DBUS_SESSION_BUS_ADDRESS="unix:abstract=/tmp/dbus-xSFd6zqrYQ,guid=dc5e07974559da016842742900000090"
declare -x DISPLAY=":0.0"

[Code]...

To be honest I cheated and used the .bashrc / .profile files from Ubuntu and all was working fine for a while now and it seems something changed to cause this... any ideas on why I am getting this? I checked my .bashrc and my /etc/profile and it doesn't look like anything is amiss..

View 3 Replies View Related

Programming :: Bash: Get Filename And Extension Using Bash?

Jan 9, 2010

I would like to get the filename (without extension) and the extension separately. The best solution I found so far is:

Let FILE="thefilenameofsomefilesfor_instance.txt"

Code:

NAME=`echo "$FILE" | cut -d'.' -f1`
EXTENSION=`echo "$FILE" | cut -d'.' -f2`

I think it would be better to count the len and remove 3 chars to right to get the extension, but it can be macintosh filenames with have 4 chars for extensions.

View 5 Replies View Related

Slackware :: If Close Terminal Ran Bash Script Inside / Bash Script Stops

Apr 28, 2011

I've noticed something, and hoped there was a work around.when I write a simple bash script, and run it, if I close the terminal i ran the bash script inside, the bash script stops. What are the solutions for this? Basically I want to run my bash script and close the terminal, keep the bash script running.

View 6 Replies View Related

General :: SSH Connection From BASH Script Stops Further BASH Script Commands

Dec 3, 2010

What happens when the script executes is that the ssh connection works and parks me at the remote hosts's shell login. Therefore, the "firefox" command refuses to execute. I need to know how to make the "ssh" connection occur, stay open, and go into the background so that the rest of the script can execute.If I could also do this with the "firefox" line so that the entire term window could be closed would also be helpful.

View 3 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved