05-27-2011
Problem with searching and then editing a file through shell.
Hi,
I have searched through this forum as there are many similar entries but could'nt get one of them to work, either that or they were just different to what I needed.
Basically I have a file, recordsDatabase. In this file are a few different fields. There is a unique identifier eg 001 which is a variable the user enters into the application.
I then want to search through the file for the unique identifier field and once the right line has been found prompt the user to enter new information which will then write over the old record and save.
The only part of the code I am struggling with is the part to actually open and edit the file.. I know sed is definately the way forward but I can't for the life of me figure out how to do it...
Any help would be greatly appreciated.
Mikey
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
I have a big file, which vi opens it with message not sufficient space with file system.
I am not adding any data in the file but changing some values within.
To make these changes effective, it asks for forced write (w!), even after doing this,
I see this particular record, change is not... (4 Replies)
Discussion started by: videsh77
4 Replies
2. UNIX for Dummies Questions & Answers
Using Solaris 8.
I need to create a shell script that will edit a text file.
I need to look in the text file and do a search and replace. For instance, the text file name is always 'filename'. I need to open filename and replace every instance of 'oldtext' with 'newtext'. 'oldtext' is static. ... (3 Replies)
Discussion started by: jowpup
3 Replies
3. Shell Programming and Scripting
Can you please help me to edit parts of a file and write into a new file.
=====================================
Suppose I have a huge data dump in a file I need to search for a tag in that and cut few lines around that tag in the file. Is there a way to keep track of line numbers and operate on... (18 Replies)
Discussion started by: jayana
18 Replies
4. Shell Programming and Scripting
For lists in sed, to say what to replace, is this correct:
I am hoping that this would recognise that either a "." is present, or that the substitution happens at the end of the line.
For files with extensions , my script works perfectly.
My problem is, files without extentions, i.e. . ... (1 Reply)
Discussion started by: busillis
1 Replies
5. Shell Programming and Scripting
Morning All: I know this might be easy but since I don't do this very often I get stumped real quick... Sun box Solaris 8 ksh...
I need to edit a file via a shell script. In this file I need to locate one specific line and then remove that line plus the next 20 line below that....
Any... (2 Replies)
Discussion started by: jimmyc
2 Replies
6. Shell Programming and Scripting
Hi ,
i am writing a script in which i am using following command to grep some string and then storing it's output to v, as like below :-
v=$(awk -F, '{ if ( $NF ~ /DEV/ ) print $0 "_BLD01";else print $0 "_RC01" }' mytest)
Here i am facing following issues:-
1. it is searcing DEV in the... (1 Reply)
Discussion started by: inderpunj
1 Replies
7. Shell Programming and Scripting
Hi,
I am having a business file in excel having charts based on data already present on it. I would like to add new rows after the existing data and refesh the chart on it using shell script.
For example--
In excel file in "sheet1", There is some data in first 10 rows ( from column A to F).... (0 Replies)
Discussion started by: sanjay1979
0 Replies
8. Shell Programming and Scripting
HI all,
I have file in the below format
1111111111_222222222_3333333
111111_22222_33333
11111111_222222_33333333333
i need to display this file like this
2222222_1111111111
22222_11111111
22222222222_1111111111111
can anyone help me with this
Thanks in advance (1 Reply)
Discussion started by: saravanan71184
1 Replies
9. Shell Programming and Scripting
Hi all,
I have a conf file, i want to update some entries in that conf file. Below is the code for that using a temporary file.
sed '/workgroup=/ c\workgroup=Workgroup' /usr/local/netx.conf > /usr/local/netx.conf.tmp
mv -f /usr/local/netx.conf.tmp /usr/local/netx.conf
Sample contents of... (9 Replies)
Discussion started by: ranj14r
9 Replies
10. Shell Programming and Scripting
value of i = solarisbox
ssh $i "cat /etc/hosts | sed "s/$i\.local\.//" | sed "s/$i\./$i/" | sed "s/$i/$i.sol.com/" > /usr/users/chidori/edit_hosts"While running the above one liner its i am not able to make the changes and write it to the file /usr/users/chidori/edit_hosts . I know there is a... (2 Replies)
Discussion started by: chidori
2 Replies
LEARN ABOUT MOJAVE
platform::shell
platform::shell(n) Tcl Bundled Packages platform::shell(n)
__________________________________________________________________________________________________________________________________________________
NAME
platform::shell - System identification support code and utilities
SYNOPSIS
package require platform::shell ?1.1.4?
platform::shell::generic shell
platform::shell::identify shell
platform::shell::platform shell
_________________________________________________________________
DESCRIPTION
The platform::shell package provides several utility commands useful for the identification of the architecture of a specific Tcl shell.
This package allows the identification of the architecture of a specific Tcl shell different from the shell running the package. The only
requirement is that the other shell (identified by its path), is actually executable on the current machine.
While for most platform this means that the architecture of the interrogated shell is identical to the architecture of the running shell
this is not generally true. A counter example are all platforms which have 32 and 64 bit variants and where a 64bit system is able to run
32bit code. For these running and interrogated shell may have different 32/64 bit settings and thus different identifiers.
For applications like a code repository it is important to identify the architecture of the shell which will actually run the installed
packages, versus the architecture of the shell running the repository software.
COMMANDS
platform::shell::identify shell
This command does the same identification as platform::identify, for the specified Tcl shell, in contrast to the running shell.
platform::shell::generic shell
This command does the same identification as platform::generic, for the specified Tcl shell, in contrast to the running shell.
platform::shell::platform shell
This command returns the contents of tcl_platform(platform) for the specified Tcl shell.
KEYWORDS
operating system, cpu architecture, platform, architecture
platform::shell 1.1.4 platform::shell(n)