05-24-2012
[Request] Copying a file with cp except for the last one or two lines.
Hi folks! I'm new to the unix-side of the world!
and I'm trying to learn as much as possible the good stuff that's in it!
So.. here comes the point.. as you can see in the title, I need to copy a file but truncating it so that last 1-2 lines are not copied... any suggests from the mastercoders?
8 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
How do i copy the common lines between 2 files to another file?
for example
file1:
asdfg
sdf
gdsf
file2:
asdfgh
asd
sdf
xcv
file3:
sdf (3 Replies)
Discussion started by: khestoi
3 Replies
2. Shell Programming and Scripting
Hi I'm in the need of a script that basically takes two files and generates a 3rd. It reads from fileA and fileB and copies lines from fileA if they start by a word of fileB.
for example
fileA
The dog is beautful
Where is your cat
Why are you sad?
Help me!
fileB
The
Where
tree
dog... (4 Replies)
Discussion started by: FrancoisCN
4 Replies
3. Shell Programming and Scripting
I have one request, First it has to create one file and in that file
it has to include some lines based on user request.
Suppose user requested 10, then script needs to add 10 lines like below
QAEVO_A1|A1
QAEVO_A2|A2
QAEVO_A3|A3
QAEVO_A4|A4
QAEVO_A5|A5
QAEVO_A6|A6
QAEVO_A7|A7... (8 Replies)
Discussion started by: sridhusha
8 Replies
4. Shell Programming and Scripting
I did a search before posting and couldn't find an example of what I need done. Anyway, I have a file called file1.txt, which has data like this:
File2.txt contains:
So what I need to do is from file1.txt find the first line M977 in file2.txt and replace the line below it with the line from... (4 Replies)
Discussion started by: Fly_Moe
4 Replies
5. Shell Programming and Scripting
I am new to Linux and have a challenging task.
I have 3 data files, and need to do the following:
Go to line 31 of file 1, delete it
Read 1 line from file 2 and add in place of deleted line
Go to line 97 of file I delete it and then read the line 1 from file 2 and add in place of that... (2 Replies)
Discussion started by: hamnsan
2 Replies
6. Shell Programming and Scripting
Hello All,
I want to copy some lines from one file to other with following condition.
Only lines between two specified strings should copy.
Example :-
"My First String "
Some_Other_String ....
Some_Other_String ....
Some_Other_String ....
"My Second String"
So only... (5 Replies)
Discussion started by: anand.shah
5 Replies
7. Shell Programming and Scripting
Hi I want to find out those unique uids from the log file which have request and response.
The log file format is as follows. This log has other irrelevant lines too but each uid should have request and reponse, I need those uids only
2013-04-03 10:51:01,808 INFO <?xml version="1.0"... (4 Replies)
Discussion started by: random_thoughts
4 Replies
8. Shell Programming and Scripting
Hi all
I have a requirement
I need to copy only first 2 lines from a file of one location to another file of same location
I used to code as
cp head -2 abc 123
But i get the following error
cp: 0653-437 123 is not a directory.
The files used are
cat abc
ABCD
EFDG
TYUI (5 Replies)
Discussion started by: Priya Amaresh
5 Replies
RBASH(1) General Commands Manual RBASH(1)
NAME
rbash - restricted bash, see bash(1)
RESTRICTED SHELL
If bash is started with the name rbash, or the -r option is supplied at invocation, the shell becomes restricted. A restricted shell is
used to set up an environment more controlled than the standard shell. It behaves identically to bash with the exception that the follow-
ing are disallowed or not performed:
o changing directories with cd
o setting or unsetting the values of SHELL, PATH, ENV, or BASH_ENV
o specifying command names containing /
o specifying a file name containing a / as an argument to the . builtin command
o specifying a filename containing a slash as an argument to the -p option to the hash builtin command
o importing function definitions from the shell environment at startup
o parsing the value of SHELLOPTS from the shell environment at startup
o redirecting output using the >, >|, <>, >&, &>, and >> redirection operators
o using the exec builtin command to replace the shell with another command
o adding or deleting builtin commands with the -f and -d options to the enable builtin command
o using the enable builtin command to enable disabled shell builtins
o specifying the -p option to the command builtin command
o turning off restricted mode with set +r or set +o restricted.
These restrictions are enforced after any startup files are read.
When a command that is found to be a shell script is executed, rbash turns off any restrictions in the shell spawned to execute the script.
SEE ALSO
bash(1)
GNU Bash-4.0 2004 Apr 20 RBASH(1)