LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-14-2012, 03:44 PM   #1
pathrosa
LQ Newbie
 
Registered: Nov 2012
Posts: 8
Blog Entries: 1

Rep: Reputation: Disabled
Help Me:I need to know which is the last of four files generated file are listed


Hi,

I am new in linux. And I need to know which is the last of four files generated file are listed. Of 4 o 5 files I need to know What is the last file created for linux commands?

Please,
Pathrosa
 
Old 11-14-2012, 03:48 PM   #2
eyanu
Member
 
Registered: Jul 2012
Location: kampala,Uganda
Distribution: backtrack
Posts: 87

Rep: Reputation: Disabled
run:
Quote:
ls -ltr
the last file to be listed is the file created last, you can even see the dates there.
 
1 members found this post helpful.
Old 11-14-2012, 04:19 PM   #3
pathrosa
LQ Newbie
 
Registered: Nov 2012
Posts: 8

Original Poster
Blog Entries: 1

Rep: Reputation: Disabled
i need the first file

Thanks eyanu,

This comand is util, but How I can get the first file the this file list? In This example:

>ls -t
file3.txt file2.txt file1.txt


I need to get only "file3.txt"

Thanks,
Pathrosa
 
Old 11-14-2012, 04:28 PM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
Code:
ls -lt *.txt |head -1

# OR

ls -ltr *.txt | tail -1
Useful links
http://rute.2038bug.com/index.html.gz
http://tldp.org/LDP/Bash-Beginners-G...tml/index.html
http://www.tldp.org/LDP/abs/html/
 
Old 11-14-2012, 05:41 PM   #5
pathrosa
LQ Newbie
 
Registered: Nov 2012
Posts: 8

Original Poster
Blog Entries: 1

Rep: Reputation: Disabled
Thanks

Thanks eyanu for yu help. This commands resolved my problem.

Pathrosa
 
Old 11-15-2012, 04:45 PM   #6
pathrosa
LQ Newbie
 
Registered: Nov 2012
Posts: 8

Original Poster
Blog Entries: 1

Rep: Reputation: Disabled
Hi eyanu!!!

I need you help Please!.

I am migrating an project of DataStage of Unix UAX to DataStage zlinux. And I have a Job that have an Stage that make an validation de unos archivos. This Stage run a script in Unix UAX, but I need migrate to zLinux. This script is the following:

echo "for i in \`ls /home/carlossz/validacion/Idc_7_val_*.asc.Z\`\\ndo\\ny=\`zcat \$i|cut -d'|' -f5|sort|uniq -c|awk '{print \$1}'|sort -u|wc -l\`\\necho \"\$i \$y\"\\ndone|grep -v \" 1\"|cut -d\" \" -f1 | sed 's/^/rm -f /g' ">/home/carlossz/validacion/Idc_7_val_ArchCif.sh; sh /home/carlossz/validacion/Idc_7_val_ArchCif.sh > /home/carlossz/validacion/Idc_7_val_borraArchCif.sh

This script run in Unix UAX without problems and I need run in zlinux as written, but when i run this script in zLinux I have the following error:

/home/carlossz/validacion/Idc_7_val_ArchCif.sh: line 1: syntax error near unexpected token `|'
/home/carlossz/validacion/Idc_7_val_ArchCif.sh: line 1: `for i in `ls /home/carlossz/validacion/Idc_7_val_*.asc.Z`\ndo\ny=`zcat $i|cut -d'|' -f5|sort|uniq -c|awk '{print $1}'|sort -u|wc -l`\necho "$i $y"\ndone|grep -v " 1"|cut -d" " -f1 | sed 's/^/rm -f /g' '


I dont know what to do....

Pathrosa
 
Old 11-15-2012, 11:47 PM   #7
eyanu
Member
 
Registered: Jul 2012
Location: kampala,Uganda
Distribution: backtrack
Posts: 87

Rep: Reputation: Disabled
pathrosa, could you please document your code for easy reading. Just enter your code and surround it with [QUOTE] tags.
 
Old 11-15-2012, 11:49 PM   #8
eyanu
Member
 
Registered: Jul 2012
Location: kampala,Uganda
Distribution: backtrack
Posts: 87

Rep: Reputation: Disabled
Or it would be better to start another thread all together....
 
Old 11-26-2012, 06:05 PM   #9
pathrosa
LQ Newbie
 
Registered: Nov 2012
Posts: 8

Original Poster
Blog Entries: 1

Rep: Reputation: Disabled
Someone, Can help me to get de substring of string, for example:

I need get substring "pruebaCuatro_prueba.txt" of "/home/carlossz/Modelo_Control/Transformaciones/Tecnologia/Modelo_control/Temporales/Ctrl_procesos_dwh/pruebaCuatro_prueba.txt"

Please Help Me,

Pathrosa
 
Old 11-26-2012, 07:05 PM   #10
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
Have you read those links I gave above?
Try http://linux.die.net/man/1/basename

You start a new thread for new questions.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Changing file permissions of generated /var/log files jeriryan Linux - Security 2 06-13-2012 09:25 AM
How to delete files keeping the files listed in a text file -urgent jeesun Linux - General 4 10-21-2011 11:28 AM
How to zip files that are listed in text file? mgltacoma Linux - Newbie 10 10-06-2011 09:30 AM
tar the files listed in other file PMP Linux - Newbie 1 04-21-2009 08:50 AM
what to do to .ppd files? i just downloaded a generated ppd file at linuxprinting? kublador Linux - Software 0 03-04-2003 04:20 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:24 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration