Terminal redirect output to file permission

Joined
Mar 7, 2015
Messages
2
Reaction score
0
Points
1
Hi!

I'm having a weird issue that I just can't wrap my head around and it's causing me issues further down the line. When I try to do the following in the terminal, in my own user home directory:

Code:
echo "hi" > testfile.txt

I am getting the file permission like this:

Code:
ls -l testfile.txt 
-rw-r--r-- 1 1675172734 3 Mar  7 11:41 testfile.txt

Is it possible to change this default file permission?

The issue that I'm trying to solve when using browserify my permissions are never executable even though the input files are.. even when supplying the -o output parameter the file still gets the same permission as above.
 
Joined
Feb 14, 2004
Messages
4,781
Reaction score
166
Points
63
Location
Groves, Texas
Are you talking about this: Browserify
Not familiar with that however is there a reason you cant do a chmod on the file to give it permissions?
Maybe in a script?
 
OP
M
Joined
Mar 7, 2015
Messages
2
Reaction score
0
Points
1
Cradom, yes, it is kind of part of a script - but more because it is part of a larger pipe of scripts and will in end end reload the generated file in my web browser - which will fail if I get the rights on the file above.

I guess I could work around it and modify the permissions inside the script, but only as a last resort. What is it that decides the permissions when doing a output redirection like this?
 

vansmith

Senior Member
Joined
Oct 19, 2008
Messages
19,943
Reaction score
578
Points
113
Location
Queensland
Your Mac's Specs
Too many devices to list
What is it that decides the permissions when doing a output redirection like this?
IIRC, it's the umask that determines the default permissions of the directory. However, I wouldn't change that for the purposes of a script and would, instead, recommend what cradom did - change the permissions of the specific file in the script itself.
 
Joined
Feb 14, 2004
Messages
4,781
Reaction score
166
Points
63
Location
Groves, Texas
I agree, change it in the script. You need to change it from the default, 644, to 755, which is read,write and execute, or -rwxr--r--.
chmod 755 filename
I tried creating a file using touch, got the same permissions, so it's the default.
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top