Sponsored Content
Top Forums UNIX for Dummies Questions & Answers How to append a string by cat and redirect to other file? Post 302941538 by stew on Friday 17th of April 2015 04:49:40 AM
Old 04-17-2015
How to append a string by cat and redirect to other file?

Hi,

when I do cat for kernel parameters

Code:
 
 
cat /proc/sys/kernel/sem >> /etc/sysctl.conf
4096    4096    32      128

The above command working with out any doubt

but I want to pass it like below, need to append "kernel.sem =" and pass it to /etc/sysctl.conf
Code:
kernel.sem = 4096    4096    32      128

I tried like

Code:
 
echo "kernel.sem ="|cat /proc/sys/kernel/sem >> /etc/sysctl.conf
print ""kernel.sem ="|cat /proc/sys/kernel/sem >> /etc/sysctl.conf

but getting error

I know awk will work, but I want to append the string by cat command.

is there any option in unix. I want run it in command prompt.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Append and redirect

Can somebody please explain to me what redirection (>) and append are? What is the difference between > and >>? Thank-you (1 Reply)
Discussion started by: Anna
1 Replies

2. Shell Programming and Scripting

variable= 'cat file|wc -l' String problems

Hi, does anybody knows about wc -l, how to transform it inot a just number? this script ALWAYS executes the command3!!, However, the value of BMU_RUNNING is 1 case $BMU_RUNNING in *0) command1 ;; *1) command 2;; *)command 3;; esac The... (3 Replies)
Discussion started by: Santiago
3 Replies

3. UNIX for Dummies Questions & Answers

How to redirect date with string command into txt file

Hello im trying to redirect the standard output into txt file but with combination of string if I do : date >! foo.txt there is no problem and im getting the date into the foo.txt but what should I do if I like to add string in the same command so the result will be in the txt : The date... (2 Replies)
Discussion started by: umen
2 Replies

4. Shell Programming and Scripting

Append (cat) to beginning of file ?

Hi, Fairly new to unix scripting, hoping to get some help. using AIX v5 Basically I have 3 files 1). Header record 2). many detail record 3). Trailer record My desired result is 1 file which contains Heaeder, Detail, Trailer Currenty I am using a series of: ... (8 Replies)
Discussion started by: CBZ
8 Replies

5. Shell Programming and Scripting

redirect cat to variable

hello just i saw a really strange for cat i have file (file1) contains line /home/rajiv/proj1/*.txt now applied a commonds DDPATH="$(cat file1)" echo $DDPATH it shows all the txt files in that folder like /home/rajiv/proj1/read1.txt /home/rajiv/proj1/read2.txt... (7 Replies)
Discussion started by: shailesh_arya
7 Replies

6. UNIX for Dummies Questions & Answers

How can i append a file name with a string

Hi All How can i append a file name with a string e.g. Lets say i have a file called ABC_TEST_1234_1.dat and i want to append the file name with a lets say 100 so the output file should look like ABC_100_TEST_1234_1.dat i have aroung 9000 file in a directory and want to... (3 Replies)
Discussion started by: Nikhilindurkar
3 Replies

7. Shell Programming and Scripting

cat redirect EOF missing text

Hello attempting to redirect out to create a startup script in solaris. The steps are working but the $1 entry is being left out. syntax below and content of output file below. cat > S99build << EOF > #!/bin/bash > case $1 in > 'start') > /usr/os-buildsol.sh > > ;; > esac > exit 0 >... (3 Replies)
Discussion started by: juanb25
3 Replies

8. Shell Programming and Scripting

Find string in file and append new string after

Hi All, I'm trying to insert a string into a file at a specific location. I'd like to add a string after the parent::__construct(); in my file. <?php if (! defined('BASEPATH')) exit('No direct script access allowed'); class MY_Controller extends CI_Controller { function... (6 Replies)
Discussion started by: jjkilpatrick
6 Replies

9. Shell Programming and Scripting

Redirect the output of the file based on String

Hi, I need to redirect the output of the file until the first instance of a string is found. So in the filename output.txt i was to redirect everything from the start to where i find this string "BEA-000377" is found to a new file called output_new.txt Sample output.txt the controller... (1 Reply)
Discussion started by: mohtashims
1 Replies

10. Shell Programming and Scripting

Cat files listed in text file and redirect to new directory with same filename

I have a directory that is restricted and I cannot just copy the files need, but I can cat them and redirect them to a new directory. The files all have the date listed in them. If I perform a long listing and grep for the date (150620) I can redirect that output to a text file. Now I need to... (5 Replies)
Discussion started by: trigger467
5 Replies
SYSCTL(8)																 SYSCTL(8)

NAME
sysctl - configure kernel parameters at runtime SYNOPSIS
sysctl [-n] [-e] variable ... sysctl [-n] [-e] [-q] -w variable=value ... sysctl [-n] [-e] [-q] -p [filename] sysctl [-n] [-e] -a sysctl [-n] [-e] -A DESCRIPTION
sysctl is used to modify kernel parameters at runtime. The parameters available are those listed under /proc/sys/. Procfs is required for sysctl support in Linux. You can use sysctl to both read and write sysctl data. PARAMETERS
variable The name of a key to read from. An example is kernel.ostype. The '/' separator is also accepted in place of a '.'. variable=value To set a key, use the form variable=value where variable is the key and value is the value to set it to. If the value contains quotes or characters which are parsed by the shell, you may need to enclose the value in double quotes. This requires the -w param- eter to use. -n Use this option to disable printing of the key name when printing values. -e Use this option to ignore errors about unknown keys. -N Use this option to only print the names. It may be useful with shells that have programmable completion. -q Use this option to not display the values set to stdout. -w Use this option when you want to change a sysctl setting. -p Load in sysctl settings from the file specified or /etc/sysctl.conf if none given. Specifying - as filename means reading data from standard input. -a Display all values currently available. -A Display all values currently available in table form. EXAMPLES
/sbin/sysctl -a /sbin/sysctl -n kernel.hostname /sbin/sysctl -w kernel.domainname="example.com" /sbin/sysctl -p /etc/sysctl.conf FILES
/proc/sys /etc/sysctl.conf SEE ALSO
sysctl.conf(5) BUGS
The -A parameter behaves just as -a does. AUTHOR
George Staikos, <staikos@0wned.org> 21 Sep 1999 SYSCTL(8)
All times are GMT -4. The time now is 07:07 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy