LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 02-27-2012, 01:55 AM   #1
katherineskye1
LQ Newbie
 
Registered: Feb 2012
Posts: 8

Rep: Reputation: Disabled
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 ...

Last edited by katherineskye1; 02-27-2012 at 01:58 AM. Reason: i add something
 
Old 02-27-2012, 02:21 AM   #2
rodrifra
Member
 
Registered: Mar 2007
Location: Spain
Distribution: Ubuntu
Posts: 199

Rep: Reputation: 36
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.
 
Old 02-27-2012, 03:12 AM   #3
katherineskye1
LQ Newbie
 
Registered: Feb 2012
Posts: 8

Original Poster
Rep: Reputation: Disabled
where can i see the .bashrc?? and what command will i typed ? to go to .bashrc?
 
Old 02-27-2012, 04:10 AM   #4
Cedrik
Senior Member
 
Registered: Jul 2004
Distribution: Slackware
Posts: 2,140

Rep: Reputation: 242Reputation: 242Reputation: 242
Code:
pico ~/.bashrc
 
Old 02-28-2012, 02:17 AM   #5
katherineskye1
LQ Newbie
 
Registered: Feb 2012
Posts: 8

Original Poster
Rep: Reputation: Disabled
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...
 
Old 02-28-2012, 03:10 PM   #6
onebuck
Moderator
 
Registered: Jan 2005
Location: Midwest USA, Central Illinois
Distribution: Slackware®
Posts: 11,380
Blog Entries: 3

Rep: Reputation: 1478Reputation: 1478Reputation: 1478Reputation: 1478Reputation: 1478Reputation: 1478Reputation: 1478Reputation: 1478Reputation: 1478Reputation: 1478
Member response

Hi,
Welcome to LQ!
Quote:
Originally Posted by katherineskye1 View Post
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!
 
Old 02-28-2012, 07:42 PM   #7
katherineskye1
LQ Newbie
 
Registered: Feb 2012
Posts: 8

Original Poster
Rep: Reputation: Disabled
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
 
Old 02-28-2012, 09:36 PM   #8
lisle2011
Member
 
Registered: Mar 2011
Location: Surrey B.C. Canada (Metro Vancouver)
Distribution: Slackware 2.6.33.4-smp
Posts: 179
Blog Entries: 1

Rep: Reputation: 25
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

Last edited by lisle2011; 02-28-2012 at 09:37 PM. Reason: repeated words there there
 
Old 02-29-2012, 01:23 AM   #9
katherineskye1
LQ Newbie
 
Registered: Feb 2012
Posts: 8

Original Poster
Rep: Reputation: Disabled
the same problem , that i had... T_T...
 
Old 02-29-2012, 02:37 AM   #10
rodrifra
Member
 
Registered: Mar 2007
Location: Spain
Distribution: Ubuntu
Posts: 199

Rep: Reputation: 36
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.
 
Old 02-29-2012, 10:55 PM   #11
katherineskye1
LQ Newbie
 
Registered: Feb 2012
Posts: 8

Original Poster
Rep: Reputation: Disabled
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??
 
Old 03-01-2012, 09:13 AM   #12
onebuck
Moderator
 
Registered: Jan 2005
Location: Midwest USA, Central Illinois
Distribution: Slackware®
Posts: 11,380
Blog Entries: 3

Rep: Reputation: 1478Reputation: 1478Reputation: 1478Reputation: 1478Reputation: 1478Reputation: 1478Reputation: 1478Reputation: 1478Reputation: 1478Reputation: 1478
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
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to change kernel time zone "dynamically" with the boot command, not with GUI?? wkcho Ubuntu 1 04-06-2010 06:23 AM
Fedora Core 2: Screen Resolution can not change from "800X600" to "1024X 768" suhaimi_sj Fedora - Installation 18 12-17-2009 04:29 AM
Standard commands give "-bash: open: command not found" even in "su -" and "su root" mibo12 Linux - General 4 11-11-2007 11:18 PM
OpenBSD: Adding a "lladdr" command to netstart to change MAC address at boot Voltar *BSD 2 04-14-2006 01:41 AM
How can you change the default setting for the "Run Command" program? whited Linux - General 6 03-01-2005 12:34 AM


All times are GMT -5. The time now is 11:14 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration