Hello Everyone,
I need help in deleting first 10 characters from the filename in a directory
eg:
1234567890samplefile1.txt
1234567890samplefile2.txt
and so on..
need to get the output as
samplefile1.txt
Thanks in Advance!!!!
Hello Everyone,
I need help in deleting first 10 characters from the filename in a directory
eg:
1234567890samplefile1.txt
1234567890samplefile2.txt
and so on..
need to get the output as
samplefile1.txt
Thanks in Advance!!!!
try:
for i in `ls *sample*.txt|sed 's/[0-9]*s/s/'`
do
cp *$i $i
done
Hi Olivia,
If it is always first 10 characters to be ignore while printing, below command may help you. List them first and using "cut" command print them from 11th character till end of file name.
ls -1|cut -c 11-
If this is not working, you can have requirement explained more clear.
Cheers,
Chanakya
file=1234567890samplefile1.txt
mv $file ${file:10}
Thanks for your reply but am getting an error as cp 1234567890samplefile1.txt and 1234567890samplefile1.txt are identical
Can you please help me out!!
breaks on files with white spaces. don't use ls with for loop like that. Use the shell.
for file in *sample*.txt
do
done
$ echo 1234567890samplefile1.txt | ruby -e 'print gets[10..-1]'
samplefile1.txt
Hi Olivia,
Could you say more clearly? or paste the error if possiable.
Thanks a Ton Chanakya!!! worked out for me