Find the answer to your Linux question:
Results 1 to 3 of 3
How do i write this bash script that changes file extension from .abc to .def in csh: > $ ls > test1.abc test2.abc test3.abc test4.abc > > > $ for ...
  1. #1
    Just Joined!
    Join Date
    Jul 2007
    Location
    San Francisco, CA
    Posts
    7

    file extension renaming (bash to csh)?

    How do i write this bash script that changes file extension from .abc to .def in csh:

    > $ ls
    > test1.abc test2.abc test3.abc test4.abc
    >
    >
    > $ for i in *.abc; do
    > > mv "$i" "${i%.abc}.def" ;
    > > done
    >
    > $ ls
    > test1.def test2.def test3.def test4.def

  2. #2
    Just Joined!
    Join Date
    Jul 2007
    Location
    San Francisco, CA
    Posts
    7
    >ls
    test1.abc test2.abc test3.abc

    >foreach n ( `ls *.abc` )
    foreach? set base = `basename $n .abc`
    foreach? mv $n $base.def
    foreach? end

    >ls
    test1.def test2.def test3.def

    >echo $shell
    /bin/csh

  3. #3
    Just Joined!
    Join Date
    Jul 2007
    Location
    San Francisco, CA
    Posts
    7
    there's also a built in csh command "rename"!


    >ls
    test1.abc test2.abc test3.abc

    >rename abc def *.abc

    >ls
    test1.def test2.def test3.def

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...