Hello. Help, please, with the code) It is necessary to change the names in the current directory to text (i) well, depending on how many of them .. just if you change them for one, they will be overwritten!
So I wrote something similar to the code. Could you help me finish it) It is only important not to touch the file where the script itself is located! This is the file "xls" Thank you so much)

ls | while read x do if [ $x != xls ] ; then echo $x | grep '^[AZ]' echo $x | grep '^[az]' if [ $? -eq 0 ] ; then y=`echo $x | sed 's/[AZ]/text'` y=`echo $x | sed 's/[az]/text'` mv $x $y fi fi done 
  • I do not understand what you want to change. Now you write that the first letter in the file name must be replaced by 'text'. For example, you get mv abc123 textbc123 mv sbc123 textbc123 mv dbc123 textbc123 Is this what you really need? (acb123 and sbc123 files will simply be included). - avp
  • I understand that I take 1 element and change only it. I just don’t know how to use grep to name the entire file name in order to completely replace it and make a text and let's say 1. how to number them .. in a folder! I understand that the code is sloppy:) for this and I ask for help) at least how to erase the entire name with text and attach the sequence number .. how can this be done? - Sleem
  • Just rename by index? I = 1 ls | while read x do if [$ x! = xls]; then mv $ x text $ II = $ (($ I + 1)) fi done - user6550
  • so simple it was .. didn't guess! Now we are going through Bash .. and I don’t like it at all ((... and when there is no desire and it doesn’t work out ... of course the logic is not correct) but what to do ((I thank!)) Thank you very much for the help!) - Sleem
  • one
    @ smile573 Now we are going through Bash .. and I don’t like it at all I sympathize, but I recommend changing preferences. - alexlz

1 answer 1

response from comment:

 I=1 ls | while read x do if [ $x != xls ] ; then mv $x text$I I=$(($I+1)) fi done