LinuxQuestions.org
Latest LQ Deal: Linux Power User 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 03-27-2012, 06:12 AM   #1
arn2025
LQ Newbie
 
Registered: Feb 2012
Posts: 26
Blog Entries: 1

Rep: Reputation: Disabled
write a script:


i have a set of commands but i want to write a script out of them, prompt one to get the file to extract, which contains abc.txt then the rest of all the commands are implemented on the abc.txt

Below are the commands/ abc.tar.gz.gz has the file abc.txt

Code:
gunzip -c abc.tar.gz.gz > extract1.tar.gz 
tar -xvf extract1.tar.gz 
awk 'BEGIN { RS="<SUBBEGIN" ; FS = "\n" } { gsub(/([A-Z]+=|;)/,"",$0 ) ; print $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17 }' abc.txt > abc.xls
$ sed 's/[^ ]*@[^ ]* //; s/&/\t/g' abc.xls > Eabc.xls

Last edited by arn2025; 03-27-2012 at 08:27 AM.
 
Old 03-27-2012, 08:08 AM   #2
arn2025
LQ Newbie
 
Registered: Feb 2012
Posts: 26
Blog Entries: 1

Original Poster
Rep: Reputation: Disabled
Urgent

how do i pause in a scrip so that one command waits for another to run, example

#!/bin/bash
gunzip -c we.tar.gz.gz > extract1.tar.gz
echo unzipping
tar -xvf extract1.tar.gz
echo unzipping extract
 
Old 03-27-2012, 08:12 AM   #3
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,251

Rep: Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684
So what is your question?

Also, please use [code][/code] tags when showing code.
 
Old 03-27-2012, 08:19 AM   #4
kb2tfa
Member
 
Registered: Oct 2006
Location: Philadelphia PA
Posts: 151

Rep: Reputation: 16
try
read -p "Press [Enter] key to start backup..."
 
Old 03-27-2012, 08:28 AM   #5
arn2025
LQ Newbie
 
Registered: Feb 2012
Posts: 26
Blog Entries: 1

Original Poster
Rep: Reputation: Disabled
i want to have these commands all in one script so i dont run line by line
 
Old 03-27-2012, 10:00 AM   #6
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 17,926

Rep: Reputation: 3690Reputation: 3690Reputation: 3690Reputation: 3690Reputation: 3690Reputation: 3690Reputation: 3690Reputation: 3690Reputation: 3690Reputation: 3690Reputation: 3690
Quote:
Originally Posted by arn2025 View Post
i want to have these commands all in one script so i dont run line by line
Ok. So take those lines and put them in a file. Make it executable. You now have a script.
 
Old 03-27-2012, 10:10 AM   #7
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,251

Rep: Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684
Must say I am curious how many fields you actually have to list out 17 in your awk entry.

Other than that +1 to TBOne's post
 
Old 03-27-2012, 10:18 AM   #8
arn2025
LQ Newbie
 
Registered: Feb 2012
Posts: 26
Blog Entries: 1

Original Poster
Rep: Reputation: Disabled
it didnt work
 
Old 03-27-2012, 10:50 AM   #9
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,251

Rep: Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684
Well you might need to explain what that means??? What didn't work? What error messages did you get?
 
Old 03-27-2012, 11:56 AM   #10
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,823

Rep: Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957
1) Please read How To Ask Questions The Smart Way, and follow the advice given there. This will help you get better responses.

2) Take some time to read up on how scripting works. I especially recommend the first link below as a good introduction to all the basic concepts.

Here are a few useful bash scripting references:
http://mywiki.wooledge.org/BashGuide
http://mywiki.wooledge.org/BashFAQ
http://mywiki.wooledge.org/BashPitfalls
http://www.linuxcommand.org/index.phphttp://tldp.org/LDP/Bash-Beginners-G...tml/index.html
http://www.tldp.org/LDP/abs/html/index.html
http://www.gnu.org/software/bash/manual/bashref.html
http://wiki.bash-hackers.org/start
http://ss64.com/bash/
 
Old 03-27-2012, 01:41 PM   #11
wpeckham
Senior Member
 
Registered: Apr 2010
Location: USA
Distribution: Debian, Ubuntu, Fedora, RedHat, DSL, Puppy, CentOS, Knoppix, Mint-DE, Sparky, Vsido, tinycore, Q4OS
Posts: 1,653

Rep: Reputation: 569Reputation: 569Reputation: 569Reputation: 569Reputation: 569Reputation: 569
No no, he did not say for the USER

You are not backgrounding any process, so the operations should be performed in order.
If you DID background a process, the usual command to pause until that process completes is "wait".
Check the man page and see if that might be what you need.
 
Old 03-27-2012, 01:42 PM   #12
jkirchner
Member
 
Registered: Apr 2007
Location: West Virginia
Distribution: LinuxMint 18
Posts: 740

Rep: Reputation: 179Reputation: 179
This thread seems to be related to this one by same OP: http://www.linuxquestions.org/questi...script-936646/
 
Old 03-27-2012, 01:49 PM   #13
AnanthaP
Member
 
Registered: Jul 2004
Location: Chennai, India
Distribution: UBUNTU 5.10 since Jul-18,2006 on Intel 820 DC
Posts: 805

Rep: Reputation: 186Reputation: 186
Create the text file and then import it to XL using open/libre office. Save the result as Eabc.xls or whatever.

OK
 
Old 03-28-2012, 10:55 AM   #14
wpeckham
Senior Member
 
Registered: Apr 2010
Location: USA
Distribution: Debian, Ubuntu, Fedora, RedHat, DSL, Puppy, CentOS, Knoppix, Mint-DE, Sparky, Vsido, tinycore, Q4OS
Posts: 1,653

Rep: Reputation: 569Reputation: 569Reputation: 569Reputation: 569Reputation: 569Reputation: 569
?? AnanthaP said WHAT?

Quote:
Create the text file and then import it to XL using open/libre office. Save the result as Eabc.xls or whatever.

OK
!!! Now I may be undercaffinated this morning, or just feeling stupid today, but I do not see how the above comment relates to any question asked in any forum anywhere on this site.


---
EVER
 
  


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
how to write a script Abdalla Linux - Newbie 8 12-30-2010 01:09 PM
How to write this script? cghcgh Programming 9 05-28-2008 05:36 AM
script to write to a cd nasirdaudahmad Linux - Hardware 3 01-24-2007 12:45 AM
how to write this script? MeganageM Linux - Newbie 1 03-10-2004 06:01 PM


All times are GMT -5. The time now is 09:06 AM.

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