# Yaml file won't interpret backslashes correctly

**URL:** https://discuss.kubernetes.io/t/yaml-file-wont-interpret-backslashes-correctly/10036
**Category:** General Discussions
**Created:** [March 12, 2020, 3:18am UTC](https://discuss.kubernetes.io/t/yaml-file-wont-interpret-backslashes-correctly/10036 "2020-03-12T03:18:54Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![raphaelc](https://avatars.discourse-cdn.com/v4/letter/r/3bc359/32.png) [@raphaelc](https://discuss.kubernetes.io/u/raphaelc)
#### Post date: [March 12, 2020, 3:18am UTC](https://discuss.kubernetes.io/t/yaml-file-wont-interpret-backslashes-correctly/10036/1 "2020-03-12T03:18:54Z")

</div>

### Cluster information:

Kubernetes version: 1.17.0  
Cloud being used: bare-metal  
Installation method: apt-get?  
Host OS: Debian 10  
CNI and version: flannel:v0.11.0  
CRI and version:

I am trying to develop a cron job that takes this rsync command:  
“find /data/high-res/ -cmin +20 -printf %P\0 | rsync -zarvhO --remove-source-files --files-from=- --from0 /data/high-res/ /mnt/high-res/”

As of now, I am trying to pass it as an args in a kubernetes manifest file

```
            args:
            - /bin/sh
            - -c
            - "find /data/high-res/ -cmin +20 -printf %P\\0 | rsync -zarvhO --remove-source-files --files-from=- --from0 /data/high-res/ /mnt/high-res/"

```

Kubernetes interprets the  
`printf %P\\0`  
as  
`printf %P\0`.

If I add another backslash as an escape character, i.e.  
`%P\\\0`,  
then it gets interpreted as  
`find /data/high-res/ -cmin +20 -printf %P\ | rsync -zarvhO --remove-source-files --files-from=- --from0 /data/high-res/ /mnt/high-res/`

What is the proper way to format the command so that it gets interpreted correctly?

I am attaching the entire yaml file below

```
apiVersion: batch/v1beta1
kind: CronJob
metadata:
  name: highres-rsync-cronjob

spec:
  schedule: "*/1 * * * *"
  concurrencyPolicy: Replace
  startingDeadlineSeconds: 10
  failedJobsHistoryLimit: 1
  successfulJobsHistoryLimit: 3
  jobTemplate:
    spec:
      template:
        spec:
          containers:
          - name: rsync-cronjob
            image: raphaelcdm/highres-rsync-cronjob:v0.1.0
            # command: ["/bin/sh", "-c", "find /data/high-res/ -cmin +20 -printf %P\\\0 \ | rsync -zarvhO --remove-source-files --files-from=- --from0 /data/high-res/ /mnt/high-res/ --exclude '*_1.egg'"]
            args:
            - /bin/sh
            - -c
            - "find /data/high-res/ -cmin +20 -printf %P\\0 | rsync -zarvhO --remove-source-files --files-from=- --from0 /data/high-res/ /mnt/high-res/"
            volumeMounts:
              - name: local-storage
                mountPath: /data/
              - name: nfs-volume
                mountPath: /mnt/
          nodeSelector:
            nfs_backup: ok
          tolerations:
            - key: is_fast_daq
              operator: Exists
              effect: NoSchedule
          restartPolicy: OnFailure
          volumes: 
          - name: local-storage
            hostPath:
              path: /data
              type: Directory
          - name: nfs-volume
            nfs:
              server: some.ip.address
              path: /data

```

As a clarification: I am trying to implement this solution for my rsync needs: [https://superuser.com/questions/1105059/how-to-rsync-files-older-than-x-min-on-linux](https://superuser.com/questions/1105059/how-to-rsync-files-older-than-x-min-on-linux)

---

<div class="post-metadata">

### Author: ![stephendotcarter](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.kubernetes.io/stephendotcarter/32/4528_2.png) [@stephendotcarter](https://discuss.kubernetes.io/u/stephendotcarter)
#### Post date: [March 12, 2020, 8:50am UTC](https://discuss.kubernetes.io/t/yaml-file-wont-interpret-backslashes-correctly/10036/2 "2020-03-12T08:50:41Z")

</div>

Did you try escaping both backslashes like this?

```auto
P\\\\0

```

Kind regards,  
Stephen

---

<div class="post-metadata">

### Author: ![raphaelc](https://avatars.discourse-cdn.com/v4/letter/r/3bc359/32.png) [@raphaelc](https://discuss.kubernetes.io/u/raphaelc)
#### Post date: [March 12, 2020, 3:23pm UTC](https://discuss.kubernetes.io/t/yaml-file-wont-interpret-backslashes-correctly/10036/3 "2020-03-12T15:23:27Z")

</div>

Thank you @stephendotcarter!
