Python: How can I read last line in file and format the text?
location: ubuntuforums.com - date: May 22, 2009
I have an issue with some of my python code.
I have a file that i need to read the last line from. Then once that line is read i need to be able to format the text. ie: remove leading spaces and some words. below is an example of the file.
Basically, i need to get the number from the last line in the file read it into a variable and convert it into an integer.
Any help is much appreciated. Thank you all very much.
How can I find a file/directory that could be anywhere on linux command line?
location: linuxexchange.com - date: January 1, 1970
Ideally, I would be able to use a program like
find [file or directory name]
to report the paths with matching filenames/directories. Unfortunately this seems to only check the current directory, not the entire folder.
I've also tried locate and which, but none find the file, even though I know its on the computer somewhere.
[SOLVED] How can I make 512byte/sector format on 4KiB/sector drive?
location: linuxquestions.com - date: November 8, 2011
I have a system which records tons of data runnning on Linux 188.8.131.52 and have a problem on hard drive.
The USB drive is 3TB, 4096-bytes per sector and formatted as ext3 with GPT and single partition.
It looks fine when I plugged and format it, but the capacity of the drive is very different as shown below.
/dev/sdb1 is the 3TB drive.
Filesystem 1k-blocks Used Available Use% Mounted on
rootfs 118784 37740 81044 32% /
/dev/sdb1 782683440 201904 782481536 0% /mnt/hdd2
I unplugged the drive and replugged it, more trouble happens.
--- kernel message on console ---
usb 1-1.1: new high speed USB device using emma-ehci and address 19
usb 1-1.1: configuration #1 chosen from 1 choice
scsi16 : SCSI emulation for USB Mass Storage devices
scsi 16:0:0:0: Direct-Access BUFFALO External HDD 0000 PQ: 0 ANSI: 5
sd 16:0:0:0: [sdb] 732566646 4096-byte hardware sectors (3000593 MB)
sd 16:0:0:0: [sdb] Wri
[BASH] How to read multiple lines from a text file?
location: linuxquestions.com - date: March 11, 2011
For example, I have a text file with data which lists numerical values from two separate individuals
How can i download a file from remote server using ftp using shell script
location: linuxquestions.com - date: April 9, 2012
I create a ftp account in server .How can i download the content from remote server automatically using ftp .
Connected to 10.200.2.34.
220 (vsFTPd 2.0.5)
Name (10.200.2.34:root): ravana
331 Please specify the password.
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
200 PORT command successful. Consider using PASV.
150 Here comes the directory listing.
drwxrwxrwx 9 0 0 4096 Apr 09 10:57 apps
drwxrwxrwx 3 510 511 4096 Apr 05 16:42 eruro
drwxrwxrwx 3 504 505 4096 Apr 03 08:08 new
-rwxrwxrwx 1 0 0 0 Mar 26 14:10 permission
drwxrwxrwx 3 508 509 4096 Apr 05 16:42 tech
drwxrwxrwx 3 509 510 4096 Apr 05 16:44 techlabs
-rwxrwxrwx 1 500 500 0 Mar 26 14:10 testing
drwxrwxrwx 3 505 506 4096 Apr 05 16:36 user1
PYTHON: how to find the newest file in a directory and open it with cat
location: ubuntuforums.com - date: July 7, 2010
i am trying to first identify the last file added to the directory and then open it with cat.
r=commands.getoutput('ls -ct1 | head -1')
if i wrote os.system(cat 'name of file') it works but not with the variable
Command to print last line of a text file
location: linuxquestions.com - date: January 24, 2007
I'm stumped, but I am trying to think of a way to print only the last line of some files that have time results at the end of them. Can `sed` or `grep` do any of these? I'm sure they can, but I am not familiar with the options.
The files have no fixed length and nothing in common. If I can just print the last line of each file, then I am set! Any suggestions would be helpful!
How can I hide a file from ls a?
location: linuxquestions.com - date: October 27, 2006
How can I hide files in an ext2/3 file system from ls -a and friends? I know about renaming the file to ".foo", but I want to do more than that--prevent listing together
how can i remove this file "gxxxx"
location: linuxquestions.com - date: January 29, 2005
I create a file named "-gxxx_file1"using touch command as follows
touch /xxxx_dir/ -gxxx_file1 " - (hyphen) is used in starting of the file name"
now i would like to remove this file ("-gxxx_file1") using rm command... when i am trying to remove this file then i got a message like "invalid option -g" just as follows ...
rm -f -gxxx_file1 then i got the message a like "rm: invalid option -- g"
any help would be appreciated... thnx in advance....
zameer ahmed syed
How to delete a line from a text file with shell script programming
location: linuxquestions.com - date: January 28, 2004
In my shell script programming, I created a text file that contains a number of records, and I want to delete a specific line after after locating it.
I am using the sed instruction to find the line number of the record that I want to delete it, but actually I don't know what commnd should I use to do it.
Take Note: I want to shift up all the records inside my file after deleting a specific record some where in the middle.
My sed command to locate the line no. is:
Page: 1 2 3 4 5 6 7 8 9 10