Review your favorite Linux distribution.
Go Back > Forums > Linux Forums > Linux - Software
User Name
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.


  Search this Thread
Old 06-07-2015, 08:48 AM   #1
LQ Newbie
Registered: Jun 2015
Posts: 1

Rep: Reputation: Disabled
Question 'echo 49 > export' could creat a file? how

Hi all,

i am new in linux. i am learning embedded linux, in a book i saw such an usage.
can anyone tell me, how echo 49 > export could creat a file name is gpio49. on the command, gpio is not written.

root@beaglebone:∼# cd /sys/class/gpio
root@beaglebone:/sys/class/gpio# ls
export gpiochip0 gpiochip32 gpiochip64 gpiochip96 unexport
root@beaglebone:/sys/class/gpio# echo 49 > export
root@beaglebone:/sys/class/gpio# ls
export gpio49 gpiochip0 gpiochip32 gpiochip64 gpiochip96 unexport

thank you
Old 06-07-2015, 10:31 AM   #2
Registered: Jan 2009
Location: Maryland-Pennsylvania border, USA
Distribution: openSUSE 15.2/15.3, Tumbleweed, Kubuntu 18.04/21.04, macOS 10.15, antiX 19, and Linux Mint 19.3
Posts: 860
Blog Entries: 45

Rep: Reputation: 120Reputation: 120
Echo standard outputs what its input - in this case "49". ">" writes the standard output of the command to the filename you give after it, in this case export.

Something's up. That command won't write a file called "gpio49"
Old 06-07-2015, 10:52 AM   #3
J Martin Rushton
Registered: Jan 2015
Location: England
Distribution: Mainly CentOS
Posts: 31

Rep: Reputation: Disabled
The filesystem is sys, that is a pseudo-filesystem for accessing parts of the OS. Contents are unlikely to be simple files. Within /sys/class most "files" are links into /sys/devices. Writing anything into these files sends a message to some aspect of a device, what the device does with it will depend upon the device.

In this case I would assume that export allows you to create a new channel to a gpio device (this is a guess), so sending "49" to it will cause gpio to create gpio49. Unless you know this level of detail for the device concerned you should not write to any devices in /sys.


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
[SOLVED] rear file names to creat a comma delimited file GRS63 Linux - Software 7 02-04-2011 12:40 AM
[SOLVED] put a file in ftp://.... and run it from my computer to creat another file ozminh Linux - Newbie 7 12-03-2010 12:23 AM
how to creat a log file raulapati Programming 8 10-07-2010 05:28 AM
Fail to creat new file in vim taureanyang Linux - Software 1 07-22-2005 12:32 AM
Can't creat file in /var/log Joe_Zhu Linux - Software 1 08-18-2004 05:12 AM > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 05:31 PM.

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