LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   how can i change command "dd" to copyconv (https://www.linuxquestions.org/questions/linux-newbie-8/how-can-i-change-command-dd-to-copyconv-931488/)

katherineskye1 02-27-2012 12:55 AM

how can i change command "dd" to copyconv
 
hi to all members in this forums .. Nice to meet you...
i only have a questions about command utility of "dd":
for example i will type:

pico trial

this is my file.

and save it and type chmod a+x trial

can there be a way that instead of typing:

dd if=trial of=trial.copy conv=ucase
so that my output in script trial will all become UPPERCASE.

And i want to change this "dd" command to "copyconv" just like the functionality of "dd" command also.. and the "conv=ucase" i would like to do the "conv=u" so that the content of my script trial will become UPPERCASE..

sample:

copyconv if=trial of=trial.copy conv=ucase OR

instead of "conv=ucase" i like the options "-u" for shortcut to uppercase and "-l" for lowercase...

sample:

copyconv if=trial of=trial.copy -u

is this possible please help ...

rodrifra 02-27-2012 01:21 AM

You can use alias to get what you want. For instance, you can modify your .bashrc adding a line like
Code:

alias copyconvU="dd conv=ucase"
So that whenever you need to convert a file to uppercase you only need to do

Code:

copyconvU if=infile of=outfile
You can also use awk's toupper function to convert a file to uppercase.

katherineskye1 02-27-2012 02:12 AM

where can i see the .bashrc?? and what command will i typed ? to go to .bashrc?

Cedrik 02-27-2012 03:10 AM

Code:

pico ~/.bashrc

katherineskye1 02-28-2012 01:17 AM

how to add new options in "dd command"
 
how can i add new options of "dd command"
like:

-u to make contents of a file uppercase and
-l to make contents of a file lowercase for example:

Code:

pico myfile
contents of file goes here...

and i type chmod a+x myfile

and i want the contents of file goes here... become uppercase when i add options of such as -u

Code:

dd -u if=myfile of=myfile
And contents of file become UPPERCASE all...
How can i do these in shell script help please...

onebuck 02-28-2012 02:10 PM

Member response
 
Hi,
Welcome to LQ!
Quote:

Originally Posted by katherineskye1 (Post 4612941)
where can i see the .bashrc?? and what command will i typed ? to go to .bashrc?

You can use a text editor of choice: vi, nano or pico to create your .bashrc & .bash_profile files.

You could setup a .bashrc & .bash_profile for your user;
Code:

sample .bash_profile;

 ~$ cat .bash_profile
 # .bash_profile
 #08-30-06 12:21
 #
 # Source .bashrc
 if [ -f ~/.bashrc ]; then
         . ~/.bashrc
 fi

Code:

sample .bashrc;
 :~$ cat .bashrc
 
#.bashrc
#08-30-06 12:20
# Add bin to path
export PATH="$PATH:/sbin:/usr/sbin:$HOME/bin"

#export PATH="$PATH:$HOME/bin"
 
 # Dynamic resizing
 shopt -s checkwinsize
  # Custom prompt
 #PS1='\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
 
 #08-29-06 11:40
 
 if [ `id -un` = root ]; then
   PS1='\[\033[1;31m\]\h:\w\$\[\033[0m\] '
  else
   PS1='\[\033[1;32m\]\h:\w\$\[\033[0m\] '
 fi
 
 #
 # Add color
 eval `dircolors -b`
 
 # User defined aliases
 alias cls='clear'
 alias clls='clear; ls'
 alias ll='ls -l'
 alias lsa='ls -A'
 alias lsg='ls | grep'
 alias lsp='ls -1 /var/log/packages/ > package-list'
 alias na='nano'
 alias web='links -g -download-dir ~/ www.google.com'
 
#08-29-06 11:50
#To clean up and cover your tracks once you log off
#Depending on your version of BASH, you might have to use
# the other form of this command
   trap "rm -f ~$LOGNAME/.bash_history" 0
#The older KSH-style form
#  trap 0 rm -f ~$LOGNAME/.bash_history

The .bashrc is very useful!

Look at links 4,5,&6 to help you to understand. Plus look at link #2 Rute for a good tutorial.

Just a few links to aid you to gaining some understanding;



1 Linux Documentation Project
2 Rute Tutorial & Exposition
3 Linux Command Guide
4 Bash Beginners Guide
5 Bash Reference Manual
6 Advanced Bash-Scripting Guide
7 Linux Newbie Admin Guide
8 LinuxSelfHelp
9 Utimate Linux Newbie Guide
10 Linux Home Networking
11 Virtualization- Top 10

The above links and others can be found at 'Slackware-Links'. More than just Slackware® links!

katherineskye1 02-28-2012 06:42 PM

in my .bash_profile
how is it that i cant add the options -l and -u

when i type:

Code:


dd -u if=file of=file.bak

and when i press enter

it says that

-u command not found

why is it...

in my .bash_profile

i typed there

alias -u='conv=ucase'
and i export it...

How is it, it didnt work... ?? what will i typed in .bash_profile

so that my -u options will implement

lisle2011 02-28-2012 08:36 PM

Bashrc etc
 
I think you should read 'man dd' and there are a list of commands that change the behavior of dd to suit the user. If dd doesn't understand the command you pass it will fail.








If I helped at all give me a pat on the back

katherineskye1 02-29-2012 12:23 AM

the same problem , that i had... T_T...

rodrifra 02-29-2012 01:37 AM

You can't use alias for parameters, just for commands. As I pointed out in my previous post, you can use an alias for a command AND one/various paramter/s and then use that alias AND provide more parameters.

katherineskye1 02-29-2012 09:55 PM

hmf.. in that case, i will not used anymore my -u options and -l options that i like to invent to have my file contents become uppercase when i only add -u options in

copyconv -u... T_T...

i'd just do the copyconvU and it works, but i like some interesting options like what i want to do in my copyconv with the -u options.. is there a way to do this inside of bash script??

onebuck 03-01-2012 08:13 AM

Member response
 
Hi,

Look at UNIX: 'The Grymoire - home for UNIX wizards'. A good intro to 'sed': An Introduction and Tutorial by Bruce Barnett

Learn to use the tools available to enhance the commands available.

"Knowledge is of two kinds. We Know a subject ourselves, or we know where we can find information upon it."- Samuel Johnson

A tool is but the extension of a man's hand and a machine is but a complex tool. He that invents a machine augments the power of man and the well being of mankind.” - Henry Ward Beecher


All times are GMT -5. The time now is 02:24 AM.