General :: How To Modify Line Of File Using Shell Script?

Apr 12, 2010

I have a file like below
n
p
1
1
50
w

I need to modify the first occurence of 1 byt some other integer.How do i do it using shell script?Can anybode help me out with that?

View 9 Replies


ADVERTISEMENT

General :: Modify A File Like /etc/gdm/custom.conf From The Shell Or A Script?

Jun 22, 2010

I want to modify a file like /etc/gdm/custom.conf from the shell or a script.

# GDM configuration storage
[xdmcp]
[debug]
[daemon]
AutomaticLoginEnable=true;
AutomaticLogin=username;

But the idea is that I can add a line to a section and it check if the section is defined, (add the definition if not), the property is defined, let it undefine (erase the line), (and delete the section header if there is no property defined), etc...

I didn't find anything except gconftool-2 but it do not explain how to modify other files. (there is a shema file there).

there isn't a program/script to achieve this, but can easyly be made for every config file, If someone do something like that, with a little database of which markup use each file, it could become really popular.

View 3 Replies View Related

General :: Shell: Script On Each Line In A File

Jan 3, 2011

So if I have a file with a list of files:

file.txt
file1.a
file2.b
file3.c

and I wanted to perform a script using a loop or recursively on each of those files, is there any way that I could do this?

I saw that xargs might be able to help me.

Here is sorta what I want to do:

Code:
#!/bin/bash

cat file.txt | xargs?? # Some commands to turn each line into a variable

for var in ${@}; do # Some way to get each of the files

# script on each file

View 1 Replies View Related

General :: Removing A Line From File Which Is Having Specific Pattern Using Shell Script?

Mar 20, 2011

I'm new to the shell scripting. can any one help in creating shell script for matching the content of the specific variable with file. it should remove that line from the file if line is containing same value as variable and keep the other content as it is.i used grep -v for accomplishing the same. But grep will remove the pattern which is similar.For eg. Assume file "test" contain datas :aaffif i used grep -v command for the pattern "a" to this file this will remove content "aa" from the file. I want the pattern only "a" should remove from the file, if it is existing. otherwise it should throw alert content not exists.

View 5 Replies View Related

General :: Write Shell Script That Takes A File Path As Command-line Arguments?

Dec 14, 2010

How can i write a shell script that takes a file path as command-line arguments.and it should report whether the path denotes a file or a directory.

View 2 Replies View Related

General :: Desire Trick To Modify Hostname In Shell Script

Mar 28, 2011

I am looking an neat trick / elegant solution to manipulate / modify hostname and set a variable to the value inside a script.I have figured what I want to do.I just want to know how to set the variable correctly ?

View 1 Replies View Related

General :: Replace Line With Another Line In Shell Script?

Feb 26, 2010

I have the file abc.txt

cat abc.txt This is a test file Nothing is new in this world

I want to replace "This is a test file" to "Text is replaced"

Code:
FindString='This is a test file'
ReplaceString='Text is replaced'
Findarray=(`echo $FindString | tr ' ' ' '`)

[Code]....

But this is not effective. how to replace entire line either using sed or awk or any other utility.

View 5 Replies View Related

Programming :: Delete A Line From File Using Shell Script?

Oct 16, 2010

i have a file containing contents as

1 2 3
2 2 3
11 2 3

now i want to delete the line which first column content is 1. so, if i pass the parametere 1 to function delete_row. is should remove the first row as

2 2 3
11 2 3

and then write the contents in file.

View 2 Replies View Related

Programming :: Shell Script Replace A Line From A File?

Mar 4, 2010

I am beginner in this business of shell script and I have no idea how to do the following: I would like to replace the lines of my file that contains 'CFL=' by 'CFL=0.5'. Note that I want to replace the full line meaning

View 11 Replies View Related

General :: Modify A File That Contains \ Using Sed Or Awk ?

May 13, 2010

I need to modify a file that contains \tsus.fbfs.comappsdataStormLossProduction and replace the \tsus.fbfs.comappsdataStormLossProduction line with rm -f /mnt/nfsvol/PC/SLR/

I have tried:

But it provides an error on the second . I need to change this in place and not redirect to another file.

Is this possible? I have used sed and awk before but not extensively.

View 7 Replies View Related

Programming :: Modify Output Of Shell Script

Dec 3, 2010

I'm running RHEL5.5 and nagios 3.2.0. The real question deals with how to change the printed output so nagios will work with it.I have made a script that will calculate network throughput on interfaces. The script is going through and finding all interfaces (eth, bond, lan) and doing the math to calculate throughput.The output is mainly for nagios to report and trend the values. As nagios wants to see nothing but perf data after the '|' character, I somehow need to have only one '|' character for all of the output.

View 2 Replies View Related

General :: Modify Another File And Not Actually Hold Information?

Feb 16, 2011

Why is the info in the (BASH_Profile) file different than (echo $Path). Is the Profile file just there to modify another file and not actually hold information?

View 1 Replies View Related

General :: First Line In Shell Scripting?

Feb 15, 2011

I am a bit confused with the first line while writing a shell script , if someone can please explain me the meaning of the first line " #!/bin/bash "the confusion for me is the # at the beginning , in shell scripting # means a comment. but in this case it loads the shell which the script must use,instead of commenting the line how is this possible. where is this defined , any particular file.

View 3 Replies View Related

Debian Configuration :: How To Modify Source.list From Shell?

Jan 27, 2011

how can i manually modify source.list to include debian repository from shell.since xorg isn't installed yet and the cd doesn't work well.

View 5 Replies View Related

Fedora :: Modify Start Up Files Of Sh-based Shell

Sep 2, 2011

i need to add a line in the login start up file(s) (one of ~/.bash_profile, ~/.bash_login, or ~/.profile) and startup file run by my shell when started as a non-login shell (~/.bashrc) so as to set up my account envirnoment for one of my courses.I don't know how to proceed with this. I tried doing this in my ubuntu enviroment and my system got locked after that.

View 3 Replies View Related

Programming :: How To Parse And Modify Keywords Using Shell Script?

Apr 14, 2011

There is a file with that format of each models' information.I don't think that's good format, but I cannot change that format. I needed to modify the model name, 'model = xxx' as 'model = abc'.And I don't know how to parse and modify 'model = iii' and 'model = ddd'.The only clue to parse 'model = ddd' is the second 'model = ' after the second 'system information'. But how to parse the second keyword?Is it possible with 'sed'?I sometimes have to modify the information of the file.using shell script if possible.Python is ok. (Shell script is better for me.)

View 15 Replies View Related

General :: Grasp The Proper Way To Modify The Sudoers File

Jun 3, 2010

Relatively new to Linux, but I'm trying to grasp the proper way to modify the sudoers file. As an example, what would I have to modify in /etc/sudoers to allow a user (say 'user1' for the example) to be able to add/remove software through yum? I'm aware of the fact that I need to use visudo and how to use the vi editor. I've Googled this topic and while I've found a number of pages on the topic, I never see many examples.

View 5 Replies View Related

General :: Modify .bashrc File To Change The HISTSIZE?

Apr 27, 2011

If I want to modify my .bashrc file to change the HISTSIZE would the following command be for example; HISTSIZE=200? And if I want to change the DEBUG_LEVEL to 8 would the following command be; DEBUG_LEVEL=8?

View 3 Replies View Related

General :: Modify The Only One Pattern Among Two Patterns In A Text File?

Nov 22, 2010

I want to replace a pattern with other pattern in a textfile. But there are two same patterns,but I need two change only the second occurence. EG:

Text file is

aaaa=1
bbbb=2
cccc=3
dddd=4

[code]....

Now I want to change aaaa=x into some other entry.

View 3 Replies View Related

General :: Scripting - Feed An Input File Into An If Statement Line-by-line

Dec 23, 2009

I am trying to write a script that takes an input file ($FileName) and an intermediate file ($FileName.info) and removes lines from $FileName if the value in $2 of $FileName.info is <75.

I can't figure out how to feed only one line of the .info file to the if statement at a time so that it will perceive it as an integer instead of a list.

The error I am getting now is ./script.sh: line 6: [: : integer expression expected

Sample input $FileName

Code:

Code:

Code:

Script so far:

Code:

View 10 Replies View Related

General :: Parse A File And Print Each Line That Ends With Matching Pattern (if The Next Line Is Blank)

Aug 2, 2010

I've written a script to parse a file and print each line that ends with matching pattern, if the next line is blank. The pattern lines are the result of md5sum $i|sed 's/path///g' so that only md5 and filename appear. Here's what I'm using.

Quote:
for fline in `sed -n '/.*.ext$/p' file1`
do
if [ "`sed -n -e '/'"$fline"'/ {n; p;}' file1`" == "" ]
then
echo ""$fline" has no info" >>file2
fi
done
[Code]....

View 4 Replies View Related

General :: Modify The /etc/host File - Change Directory Fails?

Feb 1, 2010

I am in the process of setting up an Asterisk server with Broadvoice services. I am having issues with making outbound calls and Broadvoice suggests I modify the /etc/hosts file in order to add their proxy server IP address and name. I login to my server as root and get the following command line header

[root@root tmp]#

I entered cd thinking this is what I need to change directory but fails. What is the command I need to enter in order to get to the /etc/host file so I can change it? How do I confirm an /etc/host file even exists?

View 2 Replies View Related

General :: Command Line Way To View A Line Of A File With Context?

Feb 24, 2011

I'd like show a certain line or lines of a file with context, kind of like a unified diff, on the command line in Linux:

$ (something) -l 154 stuff.py
150: def foo(bar):
151: """

[code]....

View 5 Replies View Related

General :: Appending To The Current Line In A File Instead Of Creating A New Line?

Apr 1, 2011

I am combining data from a couple different input files and creating an output file in a specific format. I notice that if I use the >> operator, information gets appended to a new line in my output file. This is useful, but if I'd like to append onto the CURRENT line, is there an easy way to do this? I've been googling around and see lots of complicated answers, nothing that suggests to me an easy way to do this. For example, if my output file looks like this:

b1a:] cat test
hello my name is
b1a:]

and I'd simply like to append "Bob", how can I do it? If I use

b1a:] echo Bob >> test
b1a:] cat test
b1a:] hello my name is
Bob
b1a:]

So what I would prefer is some command that would create the result:

hello my name is Bob

View 14 Replies View Related

General :: Replacement On More Than One Line In Text Files Using Shell

Nov 25, 2010

How can I replace one instance of a word in a text file with a piece of text that spreads several lines ? I know sed or awk is the way to go but don't know that how I can introduce new paragraphs using these tools

View 1 Replies View Related

Programming :: Delete Line Of Text From Text File Via Shell?

Jan 13, 2010

I have to delete a certain line of text from the a textfile via ubuntu's shell scripting.I have done research, and it seems that most people advocate the usage of sed /d option. sed makes does not edit the text file. Hence, most options I discovered involved the use of a temporary variable/textfile and then overwriting the old file with the temporary new file. Is there anyway whereby I can bypass the use of temporary storage containers? I hope there is any magical combination of commands to edit the file directly.

View 3 Replies View Related

General :: Shell Scripting: Parse Parameters From Command Line?

Mar 12, 2010

myscript [-a a-arg] [-c c-arg] [-b] [-e] somedirectory

Given that I want my shell script be invoked at the command line using the above parameters - where [these brackets] denote that they are optional - what is the best method to parse them?

View 1 Replies View Related

General :: Shell - Connect From Command Line To FTP Server With Proxy?

Aug 15, 2011

I want to connect to an FTP server from the Linux command line. The server is configured behind a proxy.

If I call:

echo $ftp_proxy

I get a result like this:

abc.def.ghi.jkl:8080

If I call:

ftp -pn $ftp_proxy

I get a unknown host error.

How can I connect to the FTP server using the Linux command line?

View 1 Replies View Related

General :: Udp Tcp Command Line Tool For Shell Script Programing

Feb 8, 2011

I am looking for a powerful command line tool to send and receive data via socket I mean define IP , port and data other options for command to send and receive data from sender.(like a high level socket programming)

View 4 Replies View Related

General :: Load A GTK 2.x Theme With Command Line / Shell Script?

Jul 18, 2010

I would like to know how i can load a gtk theme with a terminal command line or with a shell script if possible.

View 14 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved