LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Help Me:I need to know which is the last of four files generated file are listed (https://www.linuxquestions.org/questions/linux-newbie-8/help-me-i-need-to-know-which-is-the-last-of-four-files-generated-file-are-listed-4175437167/)

pathrosa 11-14-2012 03:44 PM

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

eyanu 11-14-2012 03:48 PM

run:
Quote:

ls -ltr
the last file to be listed is the file created last, you can even see the dates there.

pathrosa 11-14-2012 04:19 PM

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

chrism01 11-14-2012 04:28 PM

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/

pathrosa 11-14-2012 05:41 PM

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

Pathrosa

pathrosa 11-15-2012 04:45 PM

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

eyanu 11-15-2012 11:47 PM

pathrosa, could you please document your code for easy reading. Just enter your code and surround it with [QUOTE] tags.

eyanu 11-15-2012 11:49 PM

Or it would be better to start another thread all together....

pathrosa 11-26-2012 06:05 PM

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

chrism01 11-26-2012 07:05 PM

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

You start a new thread for new questions.


All times are GMT -5. The time now is 06:36 PM.