03-03-2011
need help with creating a sh script
Thank you very much for your help, unfortunately I still couldn't successfully use these scripts and I'm sure it is because I'm not understanding it correctly ;
1. Where should I locate the file that the script should read from?
2. Where should I ask it to save the changes?
3. Should I save the script in a bash script? #!/bin/sh
I will try to find these answers myself as well but I'm running out of time and so desperate to find a solution, your help again would be very much appreciated.
So far , here is what I've managed to do :
· cat cingular.txt | xargs -n10 | awk '{ print $1","$2","$3","$4","$5","$6","$7","$8","$9","$10}' ( this command managed to make my file look like this : ( this goes on for almost 6 million lines)
· 613382230,614112492,642422294,614219643,614335239,614004204,611549637,610115247,611639280,611107468,
Now here is the logic of the command that I'm looking for :
1. For every 10 lines, add “update table set location=54 (“ at the beginning of the first line and put “,0)” at the end of the 10th line.
2. Create one space line ( blank line ) after every 10 lines.
3. Repeat this task for 6000 times.
Again I really appreciate your help , thank you.
---------- Post updated at 12:55 PM ---------- Previous update was at 10:20 AM ----------
I think I figured out most of it, with a long , long way, probably you can find a much easier way.
sed 'n;n;n;n;n;n;n;n;n;n;s/^/update table set location= where location in
(/' file.txt > file2.txt
# add "," at the end of each line
sed 's/$/,/g' file.txt > file.txt
---------- Post updated at 12:56 PM ---------- Previous update was at 12:55 PM ----------
the only part that I'm stock with is this :
if a line begins with "update", add "0)" to the previous line
how can I do that through sed command ?
10 More Discussions You Might Find Interesting
1. Programming
All right. Heres the deal, I need to know everysingle command or funtion there is to create a new c file (file.c). Heres the catch: I cannot use text editors!!!:mad:
I heard of a "gcc" command is that any good?:confused:
Thanks..:cool: (2 Replies)
Discussion started by: AbRa-KaDabRa
2 Replies
2. UNIX for Dummies Questions & Answers
I am trying to create a application in OSX through UNIX that will run a script to mount an image from a CD-ROM and run the application which it corresponds to, all with double clicking on a icon in OSX. Any thoughts or ideas?
-Mad (3 Replies)
Discussion started by: madknowledge
3 Replies
3. Shell Programming and Scripting
I need to automate the following process:
I have a list of ip address for printers in a file called iplist.txt, I need to take that list and run the command
snmpget -v 1 -c public ip address sysName.0
for each ip address to see if the printer is running snmp, I want to the create a file... (4 Replies)
Discussion started by: inLine6
4 Replies
4. Shell Programming and Scripting
Hi,
I need help urgently for following issue. Pls help me to resolve this issue.
I am calling sql script file(file1.sql) from UNIX Shell Script(script1.ksh) using sql plus and trying to create flat file that contains all records returned from SQL query in SQL script(file1.sql)
I given... (6 Replies)
Discussion started by: praka
6 Replies
5. Shell Programming and Scripting
Hi,
Can someone help me with creating a bash shell script.
I need to create a script that gets a positive number n as an argument.
The script must create n directories in the current directory with names like map_1, map_2 etcetera. Each directory must be contained within its predecessor. So... (7 Replies)
Discussion started by: I-1
7 Replies
6. UNIX for Dummies Questions & Answers
Alright, well I did some more research since I originally posted this thread, and as much as I'd like to delete it, I can't, so I'll just extend my initial question a little.
Right now I have 3 scripts:
1#!/bin/bash
# script1 - Write all files modfied x days ago
find .. -daystart -mtime 0... (2 Replies)
Discussion started by: Aussiemick
2 Replies
7. Shell Programming and Scripting
Hi all
i am struggling in creating a restore of env files while doing applications clone.
the first file i created for copying the important configurations file
which is running perfect
now for reverting the changes i mean when i am restoring these files to its original places
i have to do... (7 Replies)
Discussion started by: javeedkaleem
7 Replies
8. Shell Programming and Scripting
Hi all,
I have a PLSQL script which has a IN list where it takes some ids as input. For example
SELECT * FROM EMPLOYEE WHERE EMPLOYEE_ID IN (comma separated list )
I want to run this quest inside a shell script but I would like to prepare the IN list dynamically where the employee ids... (1 Reply)
Discussion started by: LoneRanger
1 Replies
9. Shell Programming and Scripting
Hi everyone,
I am completely new to this forum and I have some questions regarding a script I am writing. I would be happy if anyone could help me with the small and precise script which should include if, then, else, while until, case and select.
The scenario is as follows:
1) A user... (3 Replies)
Discussion started by: codenotfound
3 Replies
10. UNIX for Advanced & Expert Users
Hi,
I have created customized scripts to start httpd and postgres (For CentOS 6) in /etc/init.d. However for it to work even after reboot, I have to put the script in /etc/rc.d/rc0.d, rc1.d, etc.
# ls -lrt
total 60
-rwxr-xr-x 1 root root 20199 Oct 4 2017 rc.sysinit
-rwxr-xr-x 1... (6 Replies)
Discussion started by: anaigini45
6 Replies