I'm new to C, and I'm attempting to write a script similar to the stat command for practice. I only had a problem converting st_mode to an octal permission format. I remembered I had littleutils installed which contains a script called filemode, so I checked the source and it yielded something like :
Now I'd just like to understand that bit of code. Any help is appreciated.
& by itself like that is a bitwise and, and 4095 is one away from being 4096, a nice round binary number. In binary, 4095 looks like:
All the higher-order bits, where 4095 is zero, get turned off, only the lower-order bits get let through.
C supports octal directly, though. Numbers beginning with a 0 are assumed to be octal. The value of 0777 is the same as that of 777 in the chmod sense, and you can get the same value as 4095 with the less-inexplicable octal value of 07777.
See Unix File Permissions...at least the beginning where I show how the mode is stored.
Your value of 100600 is two pieces of data. The last 4 digits tell you that the file has the same permissions as could be achieved via "chmod 600 file". So you need to isolate those 4 digits and throw away that leading 10. That is what the code is doing.
I have a .CSV file when I check for the special characters in the file using the command cat -vet filename.csv, i get very lengthy lines with "^@", "^I^@" and "^@^M" characters in between each alphabet in all of the records. Using the code below file filename.csv I get the output as
I have a... (2 Replies)
Hi,
I have an excel file in unix and I want a script which changes the excel file to .csv file i.e (comma separated value file).
Would be thankful to you if some one helps me with this.
Thanks in advance. (3 Replies)
Request if some one could provide me shell script that converts the below "input file" to "CSV format file" given
Name Domain Contact Phone Email Location
----------------------- ------------------------------------------------ ------- ----- ---------------------------------... (7 Replies)
Hi Everyone,
Can someone plesae advise on converting the inputted file into required output? First field is L then amount will - symbol.
Sample input file
B|T|SASOFTB00016|20090330|20090330|15000|9089001
B|T|SABH00000012|20090330|20090330|7000|9089003... (4 Replies)
Hi all,
How can i convert a file from one encoding to another?
Lets say I have a file which is of utf-8 encoding and I want to convert it to cp875.
Can anyone tell me how can I achieve this in shell script?
Thanks,
Sridhar (2 Replies)
Hi,
Can any suggest me some utility to convert xhtml file to postscript file format?
Also tell me from where to down load such utility..
With Regards,
Dattatray (0 Replies)