LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
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, 04: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, 04: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, 05:19 PM   #3
pathrosa
LQ Newbie
 
Registered: Nov 2012
Posts: 8
Blog Entries: 1

Original Poster
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, 05:28 PM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.9, Centos 7.3
Posts: 17,417

Rep: Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397
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, 06:41 PM   #5
pathrosa
LQ Newbie
 
Registered: Nov 2012
Posts: 8
Blog Entries: 1

Original Poster
Rep: Reputation: Disabled
Thanks

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

Pathrosa
 
Old 11-15-2012, 05:45 PM   #6
pathrosa
LQ Newbie
 
Registered: Nov 2012
Posts: 8
Blog Entries: 1

Original Poster
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-16-2012, 12:47 AM   #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-16-2012, 12:49 AM   #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, 07:05 PM   #9
pathrosa
LQ Newbie
 
Registered: Nov 2012
Posts: 8
Blog Entries: 1

Original Poster
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, 08:05 PM   #10
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.9, Centos 7.3
Posts: 17,417

Rep: Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397
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


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 10:25 AM
How to delete files keeping the files listed in a text file -urgent jeesun Linux - General 4 10-21-2011 12:28 PM
How to zip files that are listed in text file? mgltacoma Linux - Newbie 10 10-06-2011 10:30 AM
tar the files listed in other file PMP Linux - Newbie 1 04-21-2009 09:50 AM
what to do to .ppd files? i just downloaded a generated ppd file at linuxprinting? kublador Linux - Software 0 03-04-2003 05:20 AM

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

All times are GMT -5. The time now is 02:14 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration