I get this error message with the following line of code:
-sh: !.*/!!": event not found
That's an odd message, but since it wasn't going to do what you need, I'd say let it drop for now. I'm thinking on this; someone else may post some help before I do.
If French is your native language, then your English is great! It wasn't your fault -- I didn't see my misunderstanding until after I had posted.
---------- Post updated at 19:14 ---------- Previous update was at 19:09 ----------
Quote:
Originally Posted by kicker75
I can get the list I want with this line of code:
How to process each and create the directories from there? would for dir in something works? How to pipe the lists to the for dir loop?
Cool. Then this is an example of how you could make your directories:
If you want to test it before you do any damage, change mkdir to echo, or add echo before mkdir and it will just print what it would do to the screen.
Hope this is finally of some use.
Last edited by agama; 09-24-2010 at 08:16 PM..
Reason: fixed typo
If I may ask, if I want to give that script to some people, knowing that their Themes.X7N9if will be something else, like Themes.Z49fP (always 5 characters), could I use Themes.????? instead, so it works with everyone?
If I may ask, if I want to give that script to some people, knowing that their Themes.X7N9if will be something else, like Themes.Z49fP (always 5 characters), could I use Themes.????? instead, so it works with everyone?
The problem with using wildcards is if there is more than one matching name it will cause problems on the mkdir command as it will expand to two pathnames.
I would look in /var/stash for Themes directories and if there is just one, use it, and if there is more than one, prompt the user to enter the desired target.
Something like this would work (untested!!)
You then can change your mkdir statement to be:
Sorry for the long response time -- got distracted.
If you don't mind me asking one more thing, but before, here is a little explanation or what I'm trying to do now.
If someone is using my theme, prior to now, all the directories inside the loading screens directories (the .app directories), used to contain only one file, the loading screen, which was basically the same file.
As I added more and more Default.png (the file that goes there), it became clear I had to deal with this some other ways... having more than 500 loading screens, it was a bit more than 50 mb, just for the same file repeating itself.
So I created links instead, pointing to one file. I managed to search the net, and build a small script that removed the Default.png from each dir, and link instead to a Default.png located two folders up.
Now when I run the script on my iphone now, since I already ran it before, I get error messages saying cannot create, cannot link, bla bla bla.. that's normal, and doesn't matter, but would there be a clean way of dealing with this?
Also, would there be a way to determine, if there is a Default.png already there, to remove it (or even better, check if it's size is over a certain amount, like 1kb, so it's not a link but a real image, and if it's over 1kb, remove and link, and if under 1kb, skip it.)
The reason why I'm asking this, is because yesterday, when I first removed all the Default.png image and created links, I used this:
And it worked pretty good. Except that when I wanted to add that part to the creating directories script you built me earlier, I ended up with messages saying there are no Default.png to remove, which is expectable(!), but it didn't followed on the linking part. So it worked and removed all the links, and created new ones, but all those that were just created and empty, they were still empty after too, no links got created.
So from now, I'd like to determine if there is already a .app dir in /Folders, if so, check if there is a Default.png, if not, create one, if there is one, check the size or link status, and if it's higher than 1kb, or if we can determine easily if it's a file or link, remove the file, and create a link, if it's already a link, skip it.
This would make updating the loading screens directories easier once you add more apps, and would also make it easier for people with different themes, to switch to a symbolic links based model.
I hope I got my ideas clear, and if you have any questions, let me know! I'll try to explain otherwise!
Thanks a lot for your fast and spot on answers! I really appreciate your help.
(offtopic) Do you have an iphone? If so, are you into theming? Please tell me, you might be interested in seeing what I have done!
This will probably get you close enough. It is similar to the test and remove statement, but specifically checks and removes the .png only if it's a regular file, not a link. Then creates the link if it doesn't exist. I usually write scripts in Kshell, and am not sure what runs on the iPhone; I assume bash and generally Kshell scripts are compatible, but not always.
If this isn't exactly what you need, I think you'll be able to modify it. Hope it makes sense.
No, I don't have an iPhone. It's a neat platform, but honestly I want a something that I can put an external SD card into. I want to be able to manage the contents (music etc) on my own -- I don't want to be forced to use iTunes.
Hi, this was almost spot on again! Only needed to add "" so the pathnames with space are okay!
The iphone uses standard sh. Also, you can manage your songs without itunes in multiple ways with the iphone, either using mediamonkey, a jailbroken app you can also install and will enable your iphone as a usb drive, and put songs directly in it, from any computer, mac or windows, with no software installed on the pc. Don't even need itunes installed.
And there is also another app on the pc you could use, transcopy, and I think some others too.
Here is my script now:
I tried using for dir in "$tpath/*" or for dir in "$tpath" and it doesnt seem to run that part of the script. That's why I cd to it before, and then it works. I tried to replace one link with a file, and it successfully deleted it and linked instead.
Any other way I can use instead of cd'ing? And this time, no need to write it down for me, but just tell me, if I want to check if folder.app is there, I should nest a similar code you just created, but instead to look for a file, I should look for a dir?
In this case cd'ing to the directory is probably the smart way. If you really wanted to be sure, you could test that the cd command worked before going on:
Im not sure why putting it into the for loop directly didn't work, but Im tired and might be missing something obvious.
Yes, just add a check for the directory where you need it. Similar to the check for the file, but with -d.
Thanks for the scoop on the iPhone. I had assumed that iTunes was required and the fact that it can appear as a USB disk is wonderful. I might just consider one now!
Currently I am using this laborious command
lvdisplay | awk '/LV Path/ {p=$3} /LV Name/ {n=$3} /VG Name/ {v=$3} /Block device/ {d=$3; sub(".*:", "/dev/dm-", d); printf "%s\t%s\t%s\n", p, "/dev/mapper/"v"-"n, d}'
Would like to know if there is any shorter method to get this mapping of... (2 Replies)
hi,
i have a directory at /path/unix with the following files
1.txt
2.txt
3.txt
4.txt
I want to make another file called filenames.txt at a different location called /path/home. So, my output file would be
/path/home/filenames.txt with contents
/path/unix/1.txt... (1 Reply)
Hi All
I've googled around for this and can't see a way of doing it.
I have a file that contains a number of records that are layed out something like the following.
/path/to/directory/that/contains/a/file/I/need/filename.pdf
The path itself can vary both in terms of the names and the... (7 Replies)
Hello,
Given below are 2 sample paths from 2 different servers:
/opt/temp/PROD/Script/New/Letters
/opt/Share/temp/Share1/PROD/Script/Files/New/Letters
I would like to truncate the path till the folder "PROD". Please note that the field count of the folder "PROD" vaires from... (1 Reply)
Hi
In unix able to connect to oracle database and create table ,when rerun ,if table exist ,truncate that table.Any idea how to do that
a.sh
----
sqlplus -s datadmin/password <<EOF
create table xx(col1 number,
col2...
);
exit;
EOF
I... (1 Reply)
I have one file which first line is blank and second line has some data.
$cat filename
output:
30-MAY-07
I want to store 30-MAY-07 value in one variable.
for that I wrote
var="`head -2 filename`"
It will give that result but I want to truncate the first line which is blank.
plz help. (2 Replies)
Is it possibe to use sed for the following? I would like to truncate the output of a directory path if it's over 3 directory levels deep. For example:
/dir1/dir2/dir3 -- NO change required
but,
/dir1/dir2/dir3/dir4 would output as ~/dir4
Thanks. (4 Replies)
Hello everybody it's me again.
I have a procces that is writing in a 'file1' automatically but i want to truncate 'file1' to a filesize 'x' that mean if the 'file1' size is 'x' i want to delete the first lines while the last lines are being writed, that have sence?
in the process are an... (1 Reply)
what does this command do ? as in
does this command just make sure everything in the file is executed?
or does it flush the file?
Actually this is used on a file in a progress database but I believe it is a unix command? (2 Replies)