# Script program is not recognizing the -w

**URL:** <https://community.unix.com/t/script-program-is-not-recognizing-the-w/376475>\
**Category:** Shell Programming and Scripting\
**Created:** [October 20, 2019, 12:05am UTC](https://community.unix.com/t/script-program-is-not-recognizing-the-w/376475 "2019-10-20T00:05:20Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![zbest1966](https://community.unix.com/user_avatar/community.unix.com/zbest1966/32/9636_2.png) [@zbest1966](https://community.unix.com/u/zbest1966)\
**Post date:** [October 20, 2019, 12:05am UTC](https://community.unix.com/t/script-program-is-not-recognizing-the-w/376475/1 "2019-10-20T00:05:20Z")

</div>

Sorry I put -r I ment to out -w but its not perform none of -w, -r, -x flags  
Using centos 6.4

```nohighlight
#!/bin/bash
echo -e "enter the name of file :\c"
read file_name

if [-f $file_name]
then
        if [-w $file_name]
        then
          echo "Type some text date. Tp quit press crtl-"
          cat >> $file_name
        else
          echo "The file does not have permission"
        fi
    else
      echo "$file_name not exists"
 fi

```

---

<div class="post-metadata">

**Author:** ![Peasant](https://community.unix.com/user_avatar/community.unix.com/peasant/32/2251_2.png) [@Peasant](https://community.unix.com/u/Peasant)\
**Post date:** [October 20, 2019, 12:55am UTC](https://community.unix.com/t/script-program-is-not-recognizing-the-w/376475/2 "2019-10-20T00:55:49Z")

</div>

I'm not sure i follow.  
I cannot see `-w` option handled in code.

Can you be more precise on your problem and write exactly what you need / want your script to do ?

Regards  
Peasant.

---

<div class="post-metadata">

**Author:** ![nezabudka](https://community.unix.com/letter_avatar/nezabudka/32/6_449c533f586939b6e5f246632a46421f.png) [@nezabudka](https://community.unix.com/u/nezabudka)\
**Post date:** [October 20, 2019, 2:00am UTC](https://community.unix.com/t/script-program-is-not-recognizing-the-w/376475/3 "2019-10-20T02:00:15Z")

</div>

Hi

> [@zbest1966](#):
>
> ```plaintext
> if [-r $file_name]
> 
> ```

You write to the file but check for readability

---

<div class="post-metadata">

**Author:** ![system](https://community.unix.com/uploads/default/original/2X/c/c7e9e16a595259edafe88615719d5c5dcda035c2.png) [@system](https://community.unix.com/u/system)\
**Post date:** [May 27, 2020, 6:48pm UTC](https://community.unix.com/t/script-program-is-not-recognizing-the-w/376475/4 "2020-05-27T18:48:35Z")

</div>

Automatically bumped on May 27, 2020, 6:48pm UTC

Moderator comments were removed during original forum migration.

---

<div class="post-metadata">

**Author:** ![system](https://community.unix.com/uploads/default/original/2X/c/c7e9e16a595259edafe88615719d5c5dcda035c2.png) [@system](https://community.unix.com/u/system)\
**Post date:** [April 3, 2025, 2:58pm UTC](https://community.unix.com/t/script-program-is-not-recognizing-the-w/376475/5 "2025-04-03T14:58:54Z")

</div>

Automatically bumped on April 3, 2025, 2:58pm UTC


