As the title says I want to remove the first 4 letters from a folder name using a Bash script. If you have another way to do it in Linux I don't really mind e.g. Python. Also I need the script to be executed regularly (daily).
+3
A:
Since you don't mention to rename a directory or so, I assume you want simple string editing. If you want more, you should ask the right questions.
# name of the DIRECTORY (not ''folder''...)
name=fooodir
# compute a new name
editedname=${name#????}
echo "${editedname}"
TheBonsai
2009-11-12 06:27:37
Ah, missed the daily execution thing: Check your cron related manpages.
TheBonsai
2009-11-12 06:31:34
+9
A:
Another way in Bash:
$ dname=mydirectory
$ echo ${dname:4}
rectory
ghostdog74
2009-11-12 06:39:11
It should be mentioned for completeness that this parameter expansion is not ISO9945, mine is. If you stick with Bash or Korn, there shouldn't be a problem. But you should never use a #!/bin/sh Shebang when not using ISO constructs.
TheBonsai
2009-11-12 06:48:31