UNIX script unable to edit


View Poll Results: I want to store the latest .sh file to be backedup at some location say A, How can I solve this.
both 1 100.00%
do we need to change some thing in .ini file 0 0%
do we need to change some thing in .sh file 0 0%
Voters: 1. This poll is closed

 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers UNIX script unable to edit
# 1  
Old 04-23-2013
Linux UNIX script unable to edit

Hello every one,

I am a newbie , I am trying to run the script .sh file , but when I run this, I need this backup file to store at some location called " /A/B " ,but this location should only consist the latest backup file. which mean at any time this location only consists the latest backup file that is run.
But I am unable to edit the script file as I dont know much about it, Can any one give me your valuable suggestions and how to change the script so that I can have only the latest file at location "/A/B ".

Thanks
Karthik
# 2  
Old 04-23-2013
ls -t lists files ordered by date, you can get the latest that way. Putting its output through head -n 1 will print only the first, i.e. newest, file.
Code:
LATEST_FILE="$(ls -t /A/B | head -n 1 )"

echo "The latest file is ${LATEST_FILE}"

# 3  
Old 04-23-2013
Thanks
Karthik

Last edited by karthik25; 04-24-2013 at 09:11 PM.. Reason: please use code tags for your data and code
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. HP-UX

Unable to send attachment with html tables in UNIX shell script

Heyy, any help would be grateful.... LOOKING FOR THE WAYS TO SEND AN EMAIL WITH ATTACHMENT & HTML TABLES IN BODY THROUGH SHELL SCRIPT (LINUX)..NOT SURE, IF WE HAVE ANY INBUILT HTML TAG OR UNIX COMMAND TO SEND THE ATTACHMENTS. KINDLY HELP below is small script posted for our understanding..... (2 Replies)
Discussion started by: Harsha Vardhan
2 Replies

2. UNIX for Advanced & Expert Users

File edit script exceptions how to pass to script

i wrote script for if file exists script do file edit problem with the script get stuck not existing as for exit i mentioned exit 0 , and how to give the exception for script it should add ./script -- add hi ./script --add "hi how are you" now below script with case it is working for... (0 Replies)
Discussion started by: markjohn1
0 Replies

3. UNIX for Beginners Questions & Answers

Unable to edit grub2 boot screen in centos 7

I have centos 7 gui installed on vmware workstation12 on my laptop.WhenI want to pause my splash screen while starting my centos 7 using the 'esc key' nothing happens and the system just boots up.I also see a entry for aci_memory_fail... entry during the boot process.help me fix the system. (1 Reply)
Discussion started by: sabsac
1 Replies

4. HP-UX

Unable to edit the sudoers file using script

Hi All, I've made a script in order to delete the users. The script is deleting the users and removing its entry from the /etc/sudoers however it is changing the permissions of the /etc/sudoers file to the user from which it is executing the script. #!/bin/ksh #set -x print "The script... (2 Replies)
Discussion started by: Kits
2 Replies

5. Shell Programming and Scripting

Unable to edit file remotely using ssh

Hi, I am trying to edit the /etc/sudoers file using ksh, however I am unable to do that. Please find the code below: ssh $i "/usr/local/bin/sudo /usr/bin/echo "$user_id ALL=(ALL) ALL" >> /etc/sudoers" I've tried changing the double quotes to single but it is still not working. The... (3 Replies)
Discussion started by: Kits
3 Replies

6. UNIX for Dummies Questions & Answers

How to edit a file on a UNIX Server

Hi i have to edit a file on our UNIX Server, but i have no idea how to do that. The only thing that i managed till now is to get acces to it via ssh. I get into it via Terminal because i use Osx. I have the advice to edit this file: 1 - You must edit this file: / Conf /... (7 Replies)
Discussion started by: Blub
7 Replies

7. Shell Programming and Scripting

Unix Script -- Unable to perform division

I'm new to scripts, i wrote the below script to capture the percentage of FreeMemory available in Linux box. Output of UsedfreeMemory is displayed as '0'. I'm expecting the output like 0.89 (or) .89 --- ( 0.89 perferable) Anyone can help me on this pls. ... (3 Replies)
Discussion started by: murali1687
3 Replies

8. Shell Programming and Scripting

Unable to see attachment in outlook express sent by UUENCODE through unix script

Hi, I have written one script to send mail with attachment from my unix server, it is working fine, and i am capable to see the attachment in my lotus notes , but when i try to see the same thing in my outlook express ..it is completly garbaled. Please advise how to see proper attachment in... (5 Replies)
Discussion started by: apskaushik
5 Replies

9. Shell Programming and Scripting

edit columns in unix shell script

i have a file which if you will open as xls will yield something like this: Column1 Column2 Column3 ABC CDE EFG GHI IJK KLM MNO OPQ QRS what i want to need is to have this kind of results: Column1 ABC CDE EFG GHI IJK ... (10 Replies)
Discussion started by: kingpeejay
10 Replies

10. Shell Programming and Scripting

how to edit large file in unix

hi All, Plz let me know how to edit a file with 2000000 records. each record contains with 40 field seperated by |. i want modify 455487 record, but i am uable to edit this large file using vi editor in unix. plz let me know how to modify this file. Thanks in advance. -Bali Reddy (3 Replies)
Discussion started by: balireddy_77
3 Replies
Login or Register to Ask a Question