Bakunin's replacement code in post#4 is portable but still creates a new inode for the input file ("/path/to/file")
This not only denotes a repair of the original owner/group/permissions, it will make a previously hard-linked file stand-alone, and this damage cannot be repaired.
Also GNU sed -i (and perl -i) cannot preserve the original linkage.
If we are going for a real improvement then we avoid the mv command!
The cp command preserves the original inode (owner/group/permissions and linkage) - only the timestamp changes, and that's pretty correct.
This User Gave Thanks to MadeInGermany For This Post:
I am having a problem executing a sed substitute in a file. I have tried alot of different things I found in previous posts, however non seem to work.
I want to substitute this in $FILE:
VALUE=33.4
In the script I have tried the following:
prev=$(awk -F"=" '{ print $2 }' $FILE )
new=$(echo... (16 Replies)
im having trouble doing this:
i have a variable with 2 characters repeating e.g. aababbbaaaababaabbaabbba
is there a way i can search the variable for a's and b's and then change a's to b's and b's to a's?
im guessing its like getting the 1's compliment of the string
im doing this in... (2 Replies)
Hi All,
I'm currently using SED to make various changes to some .xml files I'm working on, but I'm stuck on this particular problem.
I want to remove '<placeholder>element-name</placeholder>' from the following:
<heading>Element <placeholder>element-name</placeholder> not... (2 Replies)
i am a newbie to shell script,so i want a kshell script in which i need to check for a particular character inside a file through conditional looping(like if ,case,while)and if that character exists ,then substitute a given character to that character.
consider a file test.txt,inside the file... (1 Reply)
I am trying to get rid of some ending tags but I run into some problems.
Ex.
How are you?</EndTag><Begin>It is fine.</Begin><New> Just about
I am trying to get rid of the ending tags, starts with </ and ending with >. (which is </EndTag> and </Begin>)
I tried the following
sed... (2 Replies)
I'm using sed to perform a simply search and replace. The typical data is:
<fig><image href="Graphics/BAV.gif" align="left" placement="break"
I need to replace the value in the first set of quotes, keeping the remainder of the line the same. Thus:
<fig><image href="NEW_VALUE" align="left"... (3 Replies)
Hi All,
Here is what I'm trying to do with sed:
Input File:
somechangeVariable1=Something I would like to change
somechangeVariable2=Something else I would like to change
...
Output File:
somechangeVariable1=Something I would like to different
somechangeVariable2=Something else I would... (6 Replies)
Is there a way to substitute the URL-encoding references of ( & and ` ) with their actual appearance? for example....
%26 is &
say I want to convert every %26 in my file to &.....
awk '{gsub(/%26/,"&");print}'
Is there a way to do this?
I also want to be able to convert ` too! (3 Replies)
Hi ,
I have input file like below
Hi this is "vinoth".
Hi happy to work with 'unix'
USA(united states of America)
My script variables are below :
Dquote=Ộ
Squote=&#$567
Obrac=&^986
Cbrac=&^745
I want to read the variables in my SED command to replace the double quote,single... (9 Replies)
I am trying to do what I thought should be a simple substitution, but I can't get it to work.
File:
Desire output:
I thought I'd start with a sed command to remove the part of the header line preceding the string "comp", then go on to remove the suffix of the target string (e.g. ":3-509(-)"),... (3 Replies)
Discussion started by: pathunkathunk
3 Replies
LEARN ABOUT DEBIAN
strmode
STRMODE(3) BSD Library Functions Manual STRMODE(3)NAME
strmode -- convert inode status information into a symbolic string
LIBRARY
Utility functions from BSD systems (libbsd, -lbsd)
SYNOPSIS
#include <bsd/string.h>
void
strmode(mode_t mode, char *bp);
DESCRIPTION
The strmode() function converts a file mode (the type and permission information associated with an inode, see stat(2)) into a symbolic
string which is stored in the location referenced by bp. This stored string is eleven characters in length plus a trailing NUL.
The first character is the inode type, and will be one of the following:
- regular file
b block special
c character special
d directory
l symbolic link
p fifo
s socket
w whiteout
? unknown inode type
The next nine characters encode three sets of permissions, in three characters each. The first three characters are the permissions for the
owner of the file, the second three for the group the file belongs to, and the third for the ``other'', or default, set of users.
Permission checking is done as specifically as possible. If read permission is denied to the owner of a file in the first set of permis-
sions, the owner of the file will not be able to read the file. This is true even if the owner is in the file's group and the group permis-
sions allow reading or the ``other'' permissions allow reading.
If the first character of the three character set is an ``r'', the file is readable for that set of users; if a dash ``-'', it is not read-
able.
If the second character of the three character set is a ``w'', the file is writable for that set of users; if a dash ``-'', it is not
writable.
The third character is the first of the following characters that apply:
S If the character is part of the owner permissions and the file is not executable or the directory is not searchable by the owner, and
the set-user-id bit is set.
S If the character is part of the group permissions and the file is not executable or the directory is not searchable by the group, and
the set-group-id bit is set.
T If the character is part of the other permissions and the file is not executable or the directory is not searchable by others, and the
``sticky'' (S_ISVTX) bit is set.
s If the character is part of the owner permissions and the file is executable or the directory searchable by the owner, and the set-
user-id bit is set.
s If the character is part of the group permissions and the file is executable or the directory searchable by the group, and the set-
group-id bit is set.
t If the character is part of the other permissions and the file is executable or the directory searchable by others, and the ``sticky''
(S_ISVTX) bit is set.
x The file is executable or the directory is searchable.
- None of the above apply.
The last character is a plus sign ``+'' if any there are any alternate or additional access control methods associated with the inode, other-
wise it will be a space.
SEE ALSO chmod(1), find(1), stat(2), getmode(3), setmode(3)HISTORY
The strmode() function first appeared in 4.4BSD.
BSD July 28, 1994 BSD