Bash: bad substitution (android)

BlackHawkA4

Drop the Bag
Sep 1, 2010
2,192
74
0
I'm gonna post this here because I feel like someone here would know the answer better. Even though its a android question its on the terminal emulator.

I was using terminal and was just messing around with it. I'm not a power user on windows but I can figure out how things work. Still getting into Linux.

When I CD to a dir on my SD card ( "my stuff" which I made a bunch of sub dir to stay oraganized) I get a bad substitution error message. I don't understand why.

Anyone know whats causing that? Not that I need to get in there. I get open when mounted to PC and through the file manager. can rw to it. Hmmm
 
What command are you using to get there? My guess is the space is tripping you up. I try never to use spaces or special characters in filenames or directories because it becomes a bit annoying to access them from the CLI (especially without tab completion), you may want to consider MyStuff or my-stuff or my_stuff as alternatives.

That said, the command cd my\ stuff should work just fine. The backslash is an escape character. Using cd my stuff you're passing two parameters to the cd command, by using "\ " you're telling it this is a literal space and you'll pass a single parameter to the cd command.

Alternatives involve using cd "my stuff" and cd 'my stuff'. Using double quotes says to treat most things as literal, but will still expand variables. Using single quotes will treat everything as literal.

Here's some more information and examples:
Quoting characters
 
Hey you know why I can't copy files from /system/app/ ?

I tried su and re mounting as rw. I know I can delete the apk but when I try to move it it says it's not a file or directory.

I did cp "file" /sdcard. Works for stuff on my sd card.
 
The exact command you're using and error you're seeing would help figure out what you're doing wrong, but this worked for me:

cd /sdcard/[target]
cp /system/app/[filename].app .

Note the trailing "." which says copy the files to the current active directory. IIRC, DOS implicitly assumes you want to copy the files to the current directory but Linux does not.

You can also do it in a single command by running cp /system/app/[filename].app /sdcard/[target] but without tab completion, decent up-arrow history (it does seem to work, but you don't see the command), or good ways to select text I try to chunk my commands to avoid typing.

If you find yourself on the command line frequently it may be worthwhile to install an SSH Server. Then you can SSH into your phone and type from your computer's keyboard where you've got easy access to special keys. Using ConnectBot you can also set up nifty reverse tunnels so you can connect to your computer at home and then be able to connect to your Android from there - Verizon (like most carriers, I assume) uses a NAT thanks to IPv4 exhaustion which means I can't connect to my phone directly unless it's on WiFi.
 
When in sdcard/"my stuff"/music I can cp "song".mp3 /sdcard. This will copy the file like normal to the sd card root.

When in system/app and I try to cp swype.apk /sdcard it says: "cp: can't stat 'swype.apk': No such file or directory"

Trying cp swype.apk /system returns the same error. This is with any apk in that directory.
 
That's probably your problem, Linux is case sensitive. On my Droid X (which may be different from your system) /system/app/swype.apk doesn't exist but Swype.apk does. Try this:

cp /system/app/Swype.apk "/sdcard/my stuff/"

Note that common usage has quotes around the entire directory rather than just the file with spaces. This allows you to do cd "/sdcard/my stuff/this dir/that dir" without excessive quotes.
 
From within app directory cp Swype.apk /sdcard worked.

But wait directories aren't case sensitive? I change to them no problem... Would I have this issue copying a directory without the right casing?
 
Yes, most directories in Linux are lowercase so you wouldn't run into a case issue. You can try creating a "My Stuff" directory and see if it works along with your "my stuff" directory.
 

Latest posts

Trending Posts

Forum statistics

Threads
956,347
Messages
6,967,702
Members
3,163,516
Latest member
KidColoringPage