[LINUX] Extract information using File :: Stat in Ruby

This is a memo. File :: Stat is a class of objects that stores file information. It is also used to display the user group that owns the file.

class File :: Stat \ (Ruby 2 \ .7 \ .0 Reference Manual )

module Etc \ (Ruby 2 \ .7 \ .0 Reference Manual )

require "etc"
stat = File::Stat.new("aaa.rb")

puts stat.uid #=> 501
puts stat.gid #=> 20
puts stat.size #=> 1738
puts stat.mtime #=> 2020-07-23 16:46:50.584154183 +0900
puts stat.uid #=> 501
puts Etc.getpwuid(stat.uid).name #=> uetennis
puts Etc.getgrgid(stat.gid).name #=> staff
puts File.basename("aaa.rb") #=> aaa.rb

Recommended Posts

Extract information using File :: Stat in Ruby
Extract the targz file using python
Extract zip code information using spark
Information recording memo using session in Django
Export xlsx file in C ++ using libxlsxwriter.
Create a GIF file using Pillow in Python
Extract only the file name excluding the directory in the directory
Rock-paper-scissors in Ruby
Create a MIDI file in Python using pretty_midi
Extract the lyrics information in the MP3 / MP4 file and save it in the lyrics file (* .lrc) for Sony walkman.
I tried to extract the text in the image file using Tesseract of the OCR engine
Get the file name in a folder using glob
Upload JPG file using Google Drive API in Python
Collectively register data in Firestore using csv file in Python
Create your first GDSII file in Python using gdspy
File operations in Python
File processing in Python
File operations in Python
Stat estimation using pyirt
File encryption using OpenSSL
Write a co-author network in a specific field using arxiv information
Extract classification information etc. from genbank data in xml format
Morphological analysis using Igo + mecab-ipadic-neologd in Python (with Ruby bonus)
Python: Extract file information from shared drive with Google Drive API