S
S
Seva2017-09-15 13:59:48
bash
Seva, 2017-09-15 13:59:48

How to do in bash?

Essence: there is a file in which in each line is the name of the directory that needs to be deployed.
Everything would be nothing if it were not for the newline character \r

rm -rf proxy-services

source ~/load_env.sh


SVNROOT=http://flink/svn2/mw/projects/services/ESB-Int/branches/proxy-services/
mkdir -p proxy-services
cd proxy-services
for BRANCH in `svn ls $SVNROOT --depth immediates | sed 's:/*$::'`;
  do
    if svn info $SVNROOT/$BRANCH/ci.txt 1>/dev/null 2>&1 ;
    then
      echo "File ci.txt found in $BRANCH branch..."
      echo "Fetching $BRANCH..."
      svn co $SVNROOT/$BRANCH
      cd $BRANCH
      for LINE in `cat ci.txt`;
        do
          if  [ -d `$LINE | sed 's/\\r//g'` ];    # тут все отрабатывает как надо, директория находится
          then
            echo "---- Now trying to deploy $LINE from $BRANCH..."   # попытки отбросить \r вот тут
      	    ant -buildfile ../../build4.xml -Ddeploy.type=kwsesbapu07 -Dproxy=$LINE -Dbranch=$BRANCH hdeploy-proxy # и вот тут миллионом разных способов ни к чему не привели
            cd ..
      fi
      done
    fi
  done

Everything is probably very simple here, who will tell you? I tried ${LINE%\r} - it didn't work, the regex also seems to be doing something wrong.
Thank you.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Saboteur, 2017-09-15
@Zewkin

\r is a carriage return, not a line feed.
1. Are you sure you want to remove \r, not \n ?
2. Try before "for LINE in `cat ci.txt`;" run:
dos2unix cat ci.txt
3. You can "if [ -d `$LINE | sed 's/\\r//g'` ];" replaced by

$LINE=`echo "$LINE" | tr -d "\r"`
if [ -d $LINE ];

V
Viktor Taran, 2017-09-15
@shambler81

wrote here
https://klondike-studio.ru/blog/sed-spetssimvoly/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question